一JDBC連接DB
復制代碼 代碼如下:
Class
forName("Com
ibm
db
jdbc
net
DB
Driver");
String url="jdbc:db
://dburl:port/DBname"
cn = DriverManager
getConnection( url
sUsr
sPwd );
Class
forName("Com
ibm
db
jdbc
net
DB
Driver");
String url="jdbc:db
://dburl:port/DBname"
cn = DriverManager
getConnection( url
sUsr
sPwd );
二JDBC連接Microsoft SQLServer(microsoft)
復制代碼 代碼如下:
Class
forName( "com
microsoft
jdbc
sqlserver
SQLServerDriver" );
cn = DriverManager
getConnection( "jdbc:microsoft:sqlserver://DBServerIP:
;databaseName=master"
sUsr
sPwd );
Class
forName( "com
microsoft
jdbc
sqlserver
SQLServerDriver" );
cn = DriverManager
getConnection( "jdbc:microsoft:sqlserver://DBServerIP:
;databaseName=master"
sUsr
sPwd );
三JDBC連接Sybase(jconnjar)
復制代碼 代碼如下:
Class
forName( "com
sybase
jdbc
jdbc
SybDriver" );
cn = DriverManager
getConnection( "jdbc:sybase:Tds:DBServerIP:
"
sUsr
sPwd );
Class
forName( "com
sybase
jdbc
jdbc
SybDriver" );
cn = DriverManager
getConnection( "jdbc:sybase:Tds:DBServerIP:
"
sUsr
sPwd );
四JDBC連接MySQL(mmmysqlbinjar)
復制代碼 代碼如下:
Class
forName( "org
gjt
mm
mysql
Driver" );
cn = DriverManager
getConnection( "jdbc:mysql://DBServerIP:
/myDatabaseName"
sUsr
sPwd );
Class
forName( "org
gjt
mm
mysql
Driver" );
cn = DriverManager
getConnection( "jdbc:mysql://DBServerIP:
/myDatabaseName"
sUsr
sPwd );
五JDBC連接PostgreSQL(pgjdbcjar)
復制代碼 代碼如下:
Class
forName( "org
postgresql
Driver" );
cn = DriverManager
getConnection( "jdbc:postgresql://DBServerIP/myDatabaseName"
sUsr
sPwd );
Class
forName( "org
postgresql
Driver" );
cn = DriverManager
getConnection( "jdbc:postgresql://DBServerIP/myDatabaseName"
sUsr
sPwd );
六JDBC連接Oracle(classesjar)
復制代碼 代碼如下:
Class
forName( "oracle
jdbc
driver
OracleDriver" );
cn = DriverManager
getConnection( "jdbc:oracle:thin:@MyDbComputerNameOrIP:
:ORCL"
sUsr
sPwd );
Class
forName( "oracle
jdbc
driver
OracleDriver" );
cn = DriverManager
getConnection( "jdbc:oracle:thin:@MyDbComputerNameOrIP:
:ORCL"
sUsr
sPwd );
七JDBC連接ODBC
復制代碼 代碼如下:
ClassforName( "sunjdbcodbcJdbcOdbcDriver" );
Connection cn = DriverManagergetConnection( "jdbc:odbc:" + sDsn sUsr sPwd );
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/19892.html