JDBC URL and Driver

闾丘昊然
2023-12-01
来源于网上

=====================================================================
1.Oracle数据库

OracleOracle Thin JDBC Driver
驱动程序包名:ojdbc14.jar
驱动程序类名: oracle.jdbc.driver.OracleDriver
JDBC URL:
jdbc:oracle:thin:@//<host>:<port>/ServiceName

jdbc:oracle:thin:@<host>:<port>:<SID>

Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
String url = "jdbc:oracle:thin:@localhost:1521:orcle";
String user = "test";
String password = "test";
Connection conn = DriverManager.getConnection(url, user, password);

=====================================================================
2.DB2数据库

IBM DB2IBM DB2 Universal Driver Type 4
驱动程序包名:db2jcc.jar db2jcc_license_cu.jar
驱动程序类名: com.ibm.db2.jcc.DB2Driver
JDBC URL: jdbc:db2://<host>[:<port>]/<database_name>

Class.forName("com.ibm.db2.jdbc.app.DB2Driver").newInstance();
String url = "jdbc:db2://localhost:5000/testDB";
String user = "admin";
String password = "test";
Connection conn = DriverManager.getConnection(url, user, password);

IBM DB2 Universal Driver Type 2
驱动程序包名:db2jcc.jar db2jcc_license_cu.jar
驱动程序类名: com.ibm.db2.jcc.DB2Driver
JDBC URL: jdbc:db2:<database_name>

=====================================================================
3.SQL Server数据库
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
String url = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=testDB";
String user = "sa";
String password = "test";
Connection conn = DriverManager.getConnection(url, user, password);

Microsoft SQL ServerMicrosoft SQL Server JDBC Driver (一般用来连接 SQLServer 2000)
驱动程序包名:msbase.jar mssqlserver.jar msutil.jar
驱动程序类名: com.microsoft.jdbc.sqlserver.SQLServerDriver
JDBC URL: jdbc:microsoft:sqlserver://<server_name>:<port>
默认端口1433,如果服务器使用默认端口则port可以省略

Microsoft SQL Server 2005 JDBC Driver
驱动程序包名:sqljdbc.jar
驱动程序类名: com.microsoft.sqlserver.jdbc.SQLServerDriver
JDBC URL: jdbc:sqlserver://<server_name>:<port>
默认端口1433,如果服务器使用默认端口则port可以省略


Microsoft SQLServer(http://jtds.sourceforge.net) ;
Class.forName( "net.sourceforge.jtds.jdbc.Driver" );
cn = DriverManager.getConnection( "jdbc:jtds:sqlserver://MyDbComputerNameOrIP:1433/master", sUsr, sPwd );


=====================================================================
4. Sybase数据库

SybaseSybase Adaptive Server Enterprise JDBC Driver
驱动程序包名:jconn2.jar 或jconn3.jar
驱动程序类名: com.sybase.jdbc2.jdbc.SybDriver (com.sybase.jdbc3.jdbc.SybDriver)
JDBC URL: jdbc:sybase:Tds:<host>:<port>默认端口5000

Sybase Adaptive Server Anywhere or Sybase IQ JDBC Driver
驱动程序包名:jconn2.jar 或jconn3.jar
驱动程序类名: com.sybase.jdbc2.jdbc.SybDriver (com.sybase.jdbc3.jdbc.SybDriver)
JDBC URL: jdbc:sybase:Tds:<host>:<port>?ServiceName=<database_name>
默认端口2638

Class.forName("com.sybase.jdbc.SybDriver").newInstance();
String url = "jdbc:sybase:Tds:localhost:5007/testDB";
Properties sysProps = System.getProperties();
sysProps.put("user", "userid");
sysProps.put("password", "user_password");
Connection conn = DriverManager.getConnection(url, sysProps);

=====================================================================
5.Informix数据库
InformixInformix JDBC Driver
驱动程序包名:ifxjdbc.jar
驱动程序类名: com.informix.jdbc.IfxDriver
JDBC URL: jdbc:informix-sqli://{<ip-address>|<host-name>}:<port-number>[/<dbname>]: INFORMIXSERVER=<server-name>

Class.forName("com.infoxmix.jdbc.IfxDriver").newInstance();
String url = "jdbc:infoxmix-sqli://localhost:1533/testDB:INFORMIXSERVER=myserver;user=testuser;password=testpassword";
Connection conn = DriverManager.getConnection(url);

=====================================================================
6.MySQL数据库

MySQLMySQL Connector/J Driver
驱动程序包名:mysql-connector-java-x.x.xx-bin.jar
驱动程序类名: com.mysql.jdbc.Driver
JDBC URL: jdbc:mysql://<host>:<port>/<database_name>
默认端口3306,如果服务器使用默认端口则port可以省略
MySQL Connector/J Driver 允许在URL中添加额外的连接属性jdbc:mysql://<host>:<port>/<database_name>?

property1=value1&property2=value2

Class.forName("org.gjt.mm.mysql.Driver").newInstance();
String url = "jdbc:mysql://localhost/testDB?

user=testuser&password=testpassword&useUnicode=true&characterEncoding=GB2312";
Connection conn = DriverManager.getConnection(url);

=====================================================================
7.PostgreSQL数据库

PostgreSQLPostgreSQL Native JDBC Driver
驱动程序包名:驱动程序类名: org.postgresql.Driver
JDBC URL: jdbc:postgresql://<host>:<port>/<database_name>
默认端口5432

Class.forName("org.postgresql.Driver").newInstance();
String url = "jdbc:postgresql://localhost/testDB";
String user = "myuser";
String password = "test";
Connection conn = DriverManager.getConnection(url, user, password);

=====================================================================
8 SAP DB
Class.forName ("com.sap.dbtech.jdbc.DriverSapDB");
java.sql.Connection connection = java.sql.DriverManager.getConnection ( "jdbc:sapdb://" + host + "/" +

database_name,user_name, password)

=====================================================================
9 InterBase
String url = "jdbc:interbase://localhost/e:/testbed/database/employee.gdb";
Class.forName("interbase.interclient.Driver");
//Driver d = new interbase.interclient.Driver (); /* this will also work if you do not want the line above */
Connection conn = DriverManager.getConnection( url, "sysdba", "masterkey" );

=====================================================================
10. ODBC
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
Connection cn = DriverManager.getConnection( "jdbc:odbc:" + sDsn, sUsr, sPwd );

=====================================================================
11.access
由于access并不是作为一项服务运行,所以url的方法对他不适用。access可以通过odbc,也可以通过服务器映射路径的形式找到.mdb文件

用纯java连接Access数据库,不是用jdbc-odbc连接池,有个限制就是返回数据最多是1000条

=====================================================================
12 HSqlDB
url: http://hsqldb.sourceforge.net/
driver: org.hsqldb.jdbcDriver
连接方式有4种,分别为:
con-str(内存): jdbc:hsqldb.
con-str(本地): jdbc:hsqldb:/path/to/the/db/dir
con-str(http): jdbc:hsqldb:http://dbsrv
con-str(hsql): jdbc:hsqldb:hsql://dbsrv

=====================================================================

TeradataTeradata Driver for the JDBC Interface
驱动程序包名:terajdbc4.jar tdgssjava.jar gui.jar
驱动程序类名: com.ncr.teradata.TeraDriver
JDBC URL:
Type 4: jdbc:teradata://DatabaseServerName/Param1,Param2,...
Type 3: jdbc:teradata://GatewayServerName:PortNumber
/DatabaseServerName/Param1,Param2,...

=====================================================================

NetezzaNetezza JDBC Driver
驱动程序包名:terajdbc4.jar tdgssjava.jar gui.jar
驱动程序类名: org.netezza.Driver
JDBC URL: jdbc:netezza://<host>:<port>/<database_name>
 类似资料:

相关阅读

相关文章

相关问答