该用户从未签到
|
1连接SqlServer2000 msbase.jar msutil.jar mssqlserver.jar
4 F; j% }. p0 N Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); % O( J, `! |6 o# Z j! g
String url = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=tempdb";
! T" [9 Q6 E0 i* }# c* z 2连接SqlServer2005 sqljdbc.jar
+ m$ [' P* R9 H# B Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
) L# n1 O2 F3 C2 [+ a; T$ t, K$ |' \ String url = "jdbc:sqlserver://localhost:1433;DatabaseName=tempdb"; W3 e. J- |* Y; A
0 W0 v. o- R/ x C) L7 W" Q 3. MySQL mysql-connector-java-5.0.7-bin.jar, h/ Z0 y+ r: Q9 f9 a
Class.forName( "com.mysql.jdbc.Driver" );: k; C! W/ t. x) [# a
cn = DriverManager.getConnection( "jdbc:mysql://MyDbComputerNameOrIP:3306/myDatabaseName?useUnicode=true;characterEncoding=GBK ", sUsr, sPwd );. E) a Q! T3 w- i. B8 R ]* U
2 b# M) l, A4 E- T- K/ X* k
4. Oracle(3 V& Q0 M: o) c% l, m+ ^$ r$ b6 I
//注意把oracle下的classes12.zip 改名为classes12.jar,然后拷贝到tomcat的common/lib下
9 D7 y2 h3 p6 Z5 U1 l Class.forName("oracle.jdbc.driver.OracleDriver"); ) R- M0 P& H$ Q4 S. r. G* r6 M* R* c
Connection conn= DriverManager.getConnection("jdbcracle:thinlocalhost:1521rcl",user,password);
9 z* i8 m4 w% f3 R. | . h6 d# |% c5 V
5. 使用jtds连接SQLServer2000 jtds-1.2.jar( m8 G( ]0 n X _& j0 r5 ~
Class.forName( "net.sourceforge.jtds.jdbc.Driver" );
4 q0 W1 Q$ F& e cn = DriverManager.getConnection( "jdbc:jtds:sqlserver://MyDbComputerNameOrIP:1433/数据库名", sUsr, sPwd );
1 w1 n }7 _+ I) j7 y
8 T- V& n1 e- q6 c5 Y+ k8 w ! F! O# D7 Z) Z5 _0 }5 q
6. ODBC
0 J6 g" I4 i$ A7 I% r) S Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
+ b& n9 O- U' r- S/ Z Connection cn = DriverManager.getConnection( "jdbcdbc:数据源名", sUsr, sPwd );
' s9 B1 a: k3 C7 i6 Z/ n1 |
" E7 V, Y5 |3 i: x) B 7.DB2& M0 o+ f; T' \( |- M. J/ y
Class.forName("Com.ibm.db2.jdbc.app.DB2Driver");
( r/ K: V/ U! G String url="jdbc:db2://192.9.200.108:6789/数据库名"6 b% `( R$ R6 \0 ~. a1 N% Y
cn = DriverManager.getConnection( url, sUsr, sPwd );
3 g0 d5 n; f- J3 j
# G% W+ z9 d- e, n) h. w1 A4 Z 8. PostgreSQL8 ?& u0 x$ ^ p5 ~
Class.forName( "org.postgresql.Driver" );
$ H: ^0 |& c1 h' m6 C E cn = DriverManager.getConnection( "jdbc:postgresql://MyDbComputerNameOrIP/myDatabaseName", sUsr, sPwd );
) Z* o9 a+ @) A- \! _! S ! B8 s8 K8 l1 W* O1 Q! N _' G" \
9. Sybase
3 k" U3 a7 ]3 f6 @! R Class.forName( "com.sybase.jdbc2.jdbc.SybDriver" );5 p0 |3 E9 v' r; y) ^# d
cn = DriverManager.getConnection( "jdbc:sybase:Tds:MyDbComputerNameOrIP:2638", sUsr, sPwd );& f D* t. C5 X' _$ o4 N
//(Default-Username/Password: "dba"/"sql"): b7 w5 g7 W2 l$ j6 @
4 I: h" c- V8 E/ b8 z2 _* X w6 L3 Z* ^$ X8 L( j% ?
|
|