该用户从未签到
|
1连接SqlServer2000 msbase.jar msutil.jar mssqlserver.jar# v2 k) `4 v$ p7 m$ }) G" w
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
: s3 O. a$ F( _/ T4 T% Q& r/ |& h String url = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=tempdb"; ! R; k1 g: i7 a! L: j$ t$ c% p) o
2连接SqlServer2005 sqljdbc.jar
1 G: [8 \! z+ Z: y3 A( Y Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
! D6 n. k! M& p, q9 M8 k3 J& H, P2 W String url = "jdbc:sqlserver://localhost:1433;DatabaseName=tempdb"; 7 F& ~" K8 |" ~
6 E+ C/ T( x' h5 ~; I
3. MySQL mysql-connector-java-5.0.7-bin.jar
+ c' e7 F9 v0 q) h Class.forName( "com.mysql.jdbc.Driver" );
2 d" N$ |) m; F/ v$ | cn = DriverManager.getConnection( "jdbc:mysql://MyDbComputerNameOrIP:3306/myDatabaseName?useUnicode=true;characterEncoding=GBK ", sUsr, sPwd );
- t, d7 Z7 _& t; O; \' Y/ I( [
3 U0 }; H% d" A, i9 Z' b7 q 4. Oracle(
" H- H9 H: N% a! C; L //注意把oracle下的classes12.zip 改名为classes12.jar,然后拷贝到tomcat的common/lib下
5 F0 h M4 H: J0 c2 o, u: w Class.forName("oracle.jdbc.driver.OracleDriver"); : a/ V0 s' R2 u/ F7 q1 W0 x3 J. C8 G
Connection conn= DriverManager.getConnection("jdbcracle:thinlocalhost:1521rcl",user,password); 8 d, {! y9 h- `% @" z! |
+ n! y" M. z$ v# X. O( ?. p 5. 使用jtds连接SQLServer2000 jtds-1.2.jar
$ L: B# ?* C5 F Class.forName( "net.sourceforge.jtds.jdbc.Driver" );
4 E7 e; {) c: _& [" h2 z- ] cn = DriverManager.getConnection( "jdbc:jtds:sqlserver://MyDbComputerNameOrIP:1433/数据库名", sUsr, sPwd );
5 I" a5 A0 K; D7 O4 |( E 3 d/ J+ A/ p& c2 K* j
( m+ ?0 S1 Y- Z/ R 6. ODBC
8 i, G1 a/ G0 j; Q+ f Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );+ V2 G( t) l9 n q8 ]! t- V
Connection cn = DriverManager.getConnection( "jdbcdbc:数据源名", sUsr, sPwd );: c- y2 b, T6 @/ G
$ G6 e& J9 @/ ^# t2 _ 7.DB2
9 X; [9 C# V# { Class.forName("Com.ibm.db2.jdbc.app.DB2Driver");
8 W: ~, L+ J7 Q0 H! M4 I String url="jdbc:db2://192.9.200.108:6789/数据库名"
0 z/ O0 `( V8 X% A2 `5 j cn = DriverManager.getConnection( url, sUsr, sPwd );
' ?- { I* ]7 s9 Y& N" O5 |
: C. w. J+ O5 O3 @ 8. PostgreSQL! H% S: S ]6 z6 _+ d
Class.forName( "org.postgresql.Driver" );% Z" @: a, M! e* o1 h( h0 r" C
cn = DriverManager.getConnection( "jdbc:postgresql://MyDbComputerNameOrIP/myDatabaseName", sUsr, sPwd );
5 _: z. P9 w; e a) A
" Y# X. l- @- ^* v' u, m 9. Sybase
: S* E6 }- C% v% I0 Z Class.forName( "com.sybase.jdbc2.jdbc.SybDriver" );
( t" o& |4 L B. y) _ j9 C cn = DriverManager.getConnection( "jdbc:sybase:Tds:MyDbComputerNameOrIP:2638", sUsr, sPwd );
$ y4 G5 t. j" U& j# s //(Default-Username/Password: "dba"/"sql")0 {2 _' D; L$ ?' a$ A) s) W! F
6 z: Q! t2 I/ k7 z: R
" @4 N4 F! s5 I5 W" `! @ |
|