该用户从未签到
|
1连接SqlServer2000 msbase.jar msutil.jar mssqlserver.jar
* ~, S2 J% b) Q* [! o% {1 l Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); * N9 h( \ U- g( I
String url = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=tempdb";
/ z! ^: [4 p$ i2 h4 e4 w6 `9 n1 M$ t 2连接SqlServer2005 sqljdbc.jar0 t5 i5 c7 I3 I( g6 D' u
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); 4 L/ ]3 I3 y3 b- u
String url = "jdbc:sqlserver://localhost:1433;DatabaseName=tempdb";
" T1 T% B$ e& ?1 x* h' V2 C/ l r( d% D+ [) Q& d) J
3. MySQL mysql-connector-java-5.0.7-bin.jar
3 n1 w- t, g( U0 [5 ^ Class.forName( "com.mysql.jdbc.Driver" );
6 d) B4 u v. J5 S9 n cn = DriverManager.getConnection( "jdbc:mysql://MyDbComputerNameOrIP:3306/myDatabaseName?useUnicode=true;characterEncoding=GBK ", sUsr, sPwd );
p% W# W, m8 A" _4 I- v$ }2 ]
$ `( J0 h9 V& E& U 4. Oracle(6 O( @$ B/ v" ]+ S a. c; R
//注意把oracle下的classes12.zip 改名为classes12.jar,然后拷贝到tomcat的common/lib下
/ }/ h- X2 B: G9 ^ Class.forName("oracle.jdbc.driver.OracleDriver"); 4 _0 g& a4 L, V- M4 C, ~
Connection conn= DriverManager.getConnection("jdbcracle:thinlocalhost:1521rcl",user,password); ) B& X) ~1 Q G% h: o# p* j
+ T; p! P. ] e4 Y
5. 使用jtds连接SQLServer2000 jtds-1.2.jar2 f7 ?( o2 I8 Y' S5 x
Class.forName( "net.sourceforge.jtds.jdbc.Driver" );8 @3 k1 r8 [1 _1 S. c7 t
cn = DriverManager.getConnection( "jdbc:jtds:sqlserver://MyDbComputerNameOrIP:1433/数据库名", sUsr, sPwd );5 c7 N( \8 W& J
6 ~/ w+ O8 D* I7 |
/ q! a/ D8 ~9 q! f5 H3 N 6. ODBC/ |& q( ^, Z$ _4 X
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );6 z8 j6 F/ ^3 f( f4 [, E, \1 j/ ?
Connection cn = DriverManager.getConnection( "jdbcdbc:数据源名", sUsr, sPwd );& O( q5 G/ G, d9 l. e+ r
- \. Y( ^ i1 t) H) K 7.DB2
$ Z4 `% @& X+ _- O( @! \1 }) Q2 ~' T Class.forName("Com.ibm.db2.jdbc.app.DB2Driver"); 4 C t, P# Q- B% Y O
String url="jdbc:db2://192.9.200.108:6789/数据库名"
, _1 U2 X4 N; z2 G9 J! v- L cn = DriverManager.getConnection( url, sUsr, sPwd );- b$ N; |* Y/ {: s) q
. U1 C) B! [/ k 8. PostgreSQL
) U1 t4 ^% H: j% W& b U* X% x. g8 W Class.forName( "org.postgresql.Driver" );3 y7 P$ r6 y9 \( a: G0 L
cn = DriverManager.getConnection( "jdbc:postgresql://MyDbComputerNameOrIP/myDatabaseName", sUsr, sPwd );
0 J* k, ^5 s2 N- o% J: `/ I; S2 D% x / h# e1 r/ Z6 h. p
9. Sybase9 c$ I9 r8 i9 K- \
Class.forName( "com.sybase.jdbc2.jdbc.SybDriver" );
/ z J4 M9 `* G$ `9 ]' D5 L3 f7 [9 Z cn = DriverManager.getConnection( "jdbc:sybase:Tds:MyDbComputerNameOrIP:2638", sUsr, sPwd );
5 ]- y4 y, a1 L* ~+ D/ J //(Default-Username/Password: "dba"/"sql")
+ t5 K2 o5 v _/ T0 T$ z1 f3 ~
8 m# g) h j9 c" v
6 N/ Z" V* |5 l& b7 c! C: |9 e i, A |
|