常用数据库JDBC连接写法大全

数据库
下文中主要为大家讲解常用数据库JDBC连接写法,希望对大家能够有所帮助。

常用数据库JDBC连接写法大全:

1. MySQL(http://www.mysql.com)mm.mysql-2.0.2-bin.jar

Class.forName( "org.gjt.mm.mysql.Driver" );

cn = DriverManager.getConnection( "jdbc:mysql://MyDbComputerNameOrIP:3306/myDatabaseName", sUsr, sPwd );

2. PostgreSQL(http://www.de.postgresql.org)pgjdbc2.jar

Class.forName( "org.postgresql.Driver" );

cn = DriverManager.getConnection( "jdbc:postgresql://MyDbComputerNameOrIP/myDatabaseName", sUsr, sPwd );

3. Oracle(http://www.oracle.com/ip/deploy/database/oracle9i/)classes12.zip

Class.forName( "oracle.jdbc.driver.OracleDriver" );

cn = DriverManager.getConnection( "jdbc:oracle:thin:@MyDbComputerNameOrIP:1521:ORCL", sUsr, sPwd );

4. Sybase(http://jtds.sourceforge.net)jconn2.jar

Class.forName( "com.sybase.jdbc2.jdbc.SybDriver" );

cn = DriverManager.getConnection( "jdbc:sybase:Tds:MyDbComputerNameOrIP:2638", sUsr, sPwd );

//(Default-Username/Password: "dba"/"sql")

5. Microsoft SQLServer(http://jtds.sourceforge.net)

Class.forName( "net.sourceforge.jtds.jdbc.Driver" );

cn = DriverManager.getConnection( "jdbc:jtds:sqlserver://MyDbComputerNameOrIP:1433/master", sUsr, sPwd );

6. Microsoft SQLServer(http://www.microsoft.com)

Class.forName( "com.microsoft.jdbc.sqlserver.SQLServerDriver" );

cn = DriverManager.getConnection( "jdbc:microsoft:sqlserver://MyDbComputerNameOrIP:1433;databaseName=master", sUsr, sPwd );

7. ODBC

Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );

Connection cn = DriverManager.getConnection( "jdbc:odbc:" + sDsn, sUsr, sPwd );

8.DB2

Class.forName("Com.ibm.db2.jdbc.net.DB2Driver");

String url="jdbc:db2://192.9.200.108:6789/SAMPLE"

cn = DriverManager.getConnection( url, sUsr, sPwd );

 

责任编辑:迎迎 来源: 中国IT实验室
相关推荐

2009-07-06 17:23:34

JDBC连接数据库

2010-06-04 09:33:28

连接MySQL数据库

2009-07-20 15:56:08

JDBC连接数据库步骤

2009-07-07 17:42:28

2009-07-14 17:18:23

JDBC怎么连接数据库

2009-06-19 10:28:00

JDBC连接数据库

2011-05-26 09:27:59

JDBC连接数据库

2010-08-25 11:11:59

DB2JDBC连接

2009-07-20 14:30:38

jdbc连接数据库代码

2009-06-30 14:59:36

连接数据库JSP入门

2010-08-18 16:53:35

连接DB2数据库

2010-04-22 16:56:46

Oracle数据库

2009-07-09 15:41:15

JDBC连接MySQL

2009-06-30 14:37:08

数据库JSP

2011-03-15 14:13:56

JDBCDB2数据库

2017-12-26 15:10:30

数据库Oracle操作语句

2010-04-19 14:07:02

Oracle数据库

2009-07-07 17:27:37

JDBC连接Oracl

2010-07-30 09:57:31

2010-03-04 17:19:40

点赞
收藏

51CTO技术栈公众号