java获取数据库连接类型_Java中JDBC获取各种类型数据库连
接
1
. Microsoft SQLServer(http:
//
www.microsoft)
(SqlServer 2000)
Class.forName(
"
com.microsoft.jdbc.sqlserver.SQLServerDriver
"
)
;
cn
=
"
jdbc:microsoft:sqlserver://localhost:1433;databaseName=pubs
"
, sUsr, sPwd );
(SqlServer 2005)
Class.forName(
"
com.microsoft.sqlserver.jdbc.SQLServerDriver
"
);
cn
=
"
jdbc:sqlserver://localhost:1433;databaseName=pubs
"
(http:
//
"
oracle.jdbc.driver.OracleDriver
"
);
cn
=
"
jdbc:oracle:thin:@MyDbComputerNameOrIP:1521:ORCL
"
,
sUsr, sPwd );
3. MySQL
(http:
//
Class.forName(
"
sql.Driver
"
java的jdbc连接数据库);
cn
=
"
jdbc:mysql://MyDbComputerNameOrIP:3306/myDatabaseName "
, sUsr, sPwd );
4
www.)pgjdbc2.jar
Class.forName(
"
org.postgresql.Driver
"
)
;
cn
=
"
jdbc:postgresql://MyDbComputerNameOrIP/myDatabaseName "
, sUsr, sPwd );
5
. Sybase(http:
//
jtds.sourceforge)jconn2.jar
Class.forName(
"
com.sybase.jdbc2.jdbc.SybDriver
"
);
cn
=
"
jdbc:sybase:Tds:MyDbComputerNameOrIP:2638
"
,
sUsr, sPwd );
//
(Default-Username/Password: "dba"/"sql")
6
jtds.sourceforge)
Class.forName(
"
net.sourceforge.jtds.jdbc.Driver
"
);
cn
=
"
jdbc:jtds:sqlserver://MyDbComputerNameOrIP:1433/master "
, sUsr, sPwd );
7
. ODBC
Class.forName(
"
sun.jdbc.odbc.JdbcOdbcDriver
"
)
;
Connection cn
=
"
jdbc:odbc:
"
+
sDsn, sUsr, sPwd );
8.DB2(新添加)
Class.forName(
"
com.ibm.db2.jdbc.DB2Driver
String url
=
"
jdbc:db2://192.9.200.108:6789/SAMPLE
"
cn
=
9.Microsoft SQL Server series (6.5, 7.x and 2000) and Sybase 10 JDBC Name: jTDS
URL: http:
//
jtds.sourceforge/
Version:
0.5
.
1
Download URL: http:
//
sourceforge/project/showfiles.php?group_id=33291
语法:
Class.forName(
"
net.sourceforge.jtds.jdbc.Driver
"
);
Connection con
=
"
jdbc:jtds:sqlserver://host:port/database
"
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论