Home > Database > Mysql Tutorial > body text

连接各种数据库的驱动及url

WBOY
Release: 2016-06-07 15:07:25
Original
1202 people have browsed it

SQL Server com.microsoft.jdbc.sqlserver.SQLServerDriver jdbc:microsoft:sqlserver://localhost:1433;databasename=dbname ? Oracle oracle.jdbc.driver.OracleDriver jdbc:oracle:thin:@localhost:1521:dbname MySQL com.mysql.jdbc.Driver jdbc:mysql:/

SQL Server
com.microsoft.jdbc.sqlserver.SQLServerDriver
jdbc:microsoft:sqlserver://localhost:1433;databasename=dbname

?

Oracle
oracle.jdbc.driver.OracleDriver
jdbc:oracle:thin:@localhost:1521:dbname


MySQL
com.mysql.jdbc.Driver
jdbc:mysql://localhost:3306/dbname

?

MS SQLServer

com.microsoft.sqlserver.jdbc.SQLServerDriver

jdbc:sqlserver:localhost:1433;DatabaseName=dbname

?

Sybase

com.p6spy.engine.spy.P6SpyDriver

jdbc:sybase:Tds:localhost:5000/dbname?charset=cp936&jconnect_version=5&language=us_english

?

ODBC-JDBC桥
sun.jdbc.odbc.JdbcOdbcDriver
jdbc:odbc:ds_name

?


一、JDBC连接DB2

Java代码 复制代码?收藏代码

  1. Class.forName("Com.ibm.db2.jdbc.net.DB2Driver");? ??
  2. String?url="jdbc:db2://dburl:port/DBname"? ??
  3. cn?=?DriverManager.getConnection(?url,?sUsr,?sPwd?);??
Class.forName("Com.ibm.db2.jdbc.net.DB2Driver"); 
String url="jdbc:db2://dburl:port/DBname" 
cn = DriverManager.getConnection( url, sUsr, sPwd );
Copy after login


二、JDBC连接Microsoft SQLServer(microsoft)

Java代码 复制代码?收藏代码

  1. Class.forName(?"com.microsoft.jdbc.sqlserver.SQLServerDriver"?);? ??
  2. cn?=?DriverManager.getConnection(?"jdbc:microsoft:sqlserver://DBServerIP:1433;databaseName=master",?sUsr,?sPwd?);???

Class.forName( "com.microsoft.jdbc.sqlserver.SQLServerDriver" ); 
cn = DriverManager.getConnection( "jdbc:microsoft:sqlserver://DBServerIP:1433;databaseName=master", sUsr, sPwd ); 
Copy after login



三、JDBC连接Sybase(jconn2.jar)

Java代码 复制代码?收藏代码

  1. Class.forName(?"com.sybase.jdbc2.jdbc.SybDriver"?);? ??
  2. cn?=?DriverManager.getConnection(?"jdbc:sybase:Tds:DBServerIP:2638",?sUsr,?sPwd?);???

Class.forName( "com.sybase.jdbc2.jdbc.SybDriver" ); 
cn = DriverManager.getConnection( "jdbc:sybase:Tds:DBServerIP:2638", sUsr, sPwd ); 
Copy after login



四、JDBC连接MySQL(mm.mysql-3.0.2-bin.jar)

Java代码 复制代码?收藏代码

  1. Class.forName(?"org.gjt.mm.mysql.Driver"?);? ??
  2. cn?=?DriverManager.getConnection(?"jdbc:mysql://DBServerIP:3306/myDatabaseName",?sUsr,?sPwd?);???

Class.forName( "org.gjt.mm.mysql.Driver" ); 
cn = DriverManager.getConnection( "jdbc:mysql://DBServerIP:3306/myDatabaseName", sUsr, sPwd ); 
Copy after login



五、JDBC连接PostgreSQL(pgjdbc2.jar)

Java代码 复制代码?收藏代码

  1. Class.forName(?"org.postgresql.Driver"?);? ??
  2. cn?=?DriverManager.getConnection(?"jdbc:postgresql://DBServerIP/myDatabaseName",?sUsr,?sPwd?);???

Class.forName( "org.postgresql.Driver" ); 
cn = DriverManager.getConnection( "jdbc:postgresql://DBServerIP/myDatabaseName", sUsr, sPwd ); 
Copy after login



六、JDBC连接Oracle(classes12.jar)

Java代码 复制代码?收藏代码

  1. Class.forName(?"oracle.jdbc.driver.OracleDriver"?);? ??
  2. cn?=?DriverManager.getConnection(?"jdbc:oracle:thin:@MyDbComputerNameOrIP:1521:ORCL",?sUsr,?sPwd?);???

Class.forName( "oracle.jdbc.driver.OracleDriver" ); 
cn = DriverManager.getConnection( "jdbc:oracle:thin:@MyDbComputerNameOrIP:1521:ORCL", sUsr, sPwd ); 
Copy after login



七、JDBC连接ODBC

Java代码 复制代码?收藏代码

  1. Class.forName(?"sun.jdbc.odbc.JdbcOdbcDriver"?);? ??
  2. Connection?cn?=?DriverManager.getConnection(?"jdbc:odbc:"?+?sDsn,?sUsr,?sPwd?);?
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template