一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 );