该用户从未签到
|
1连接SqlServer2000 msbase.jar msutil.jar mssqlserver.jar# ?5 k: T1 W( n1 l7 V
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); ( z" u/ z; N4 B- e! T# {6 _9 I, r
String url = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=tempdb"; 6 E) Z$ W+ F& a% \* b2 w! l7 q: f. y
2连接SqlServer2005 sqljdbc.jar
: k9 k* j0 [. Q8 j5 D Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
9 E4 Z( ^$ M+ E, {, }! t5 d& a9 k String url = "jdbc:sqlserver://localhost:1433;DatabaseName=tempdb";
6 k3 n; q" e+ p* Z; ]0 {8 v
3 m$ R4 @- \) S+ ` 3. MySQL mysql-connector-java-5.0.7-bin.jar% i# R+ S5 |3 e% H+ H$ z/ r
Class.forName( "com.mysql.jdbc.Driver" );
$ m" }& k: y# X4 \# i3 o; {0 o3 U cn = DriverManager.getConnection( "jdbc:mysql://MyDbComputerNameOrIP:3306/myDatabaseName?useUnicode=true;characterEncoding=GBK ", sUsr, sPwd );
: G$ e" O T( W: u' A- k& s / i) B9 O) N; Y# |
4. Oracle(
5 S3 D1 \0 F; X' S" x# c4 y //注意把oracle下的classes12.zip 改名为classes12.jar,然后拷贝到tomcat的common/lib下; P' c# y) y/ d" ?# c9 r
Class.forName("oracle.jdbc.driver.OracleDriver"); " t% ?1 S) a r# y8 u+ s& j
Connection conn= DriverManager.getConnection("jdbcracle:thinlocalhost:1521rcl",user,password); 0 I( ^$ O- S/ d ~6 I
/ y6 ~) B1 h. c2 { 5. 使用jtds连接SQLServer2000 jtds-1.2.jar
+ P8 \9 C* m, I% m Class.forName( "net.sourceforge.jtds.jdbc.Driver" );
0 x: }" F8 X# l3 r. T, k cn = DriverManager.getConnection( "jdbc:jtds:sqlserver://MyDbComputerNameOrIP:1433/数据库名", sUsr, sPwd );) T7 C+ M* a" E( R) `7 `* B4 t Z
6 k( J6 [; G S( B
6 z' v3 _' S) U, X! o
6. ODBC
' U4 @( ]% e7 y2 | Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
9 ^* T- U5 N: Y5 W t j Connection cn = DriverManager.getConnection( "jdbcdbc:数据源名", sUsr, sPwd );
* x, b$ @7 Y( J! U8 n* V
4 Z+ e7 o7 c# x; Q" g3 U 7.DB2
9 S/ m$ @- B" U6 u* J: a5 q Class.forName("Com.ibm.db2.jdbc.app.DB2Driver"); 3 ]& W8 v {% k- m: }; x! {8 T! Y
String url="jdbc:db2://192.9.200.108:6789/数据库名") \: [: a( M F/ ~- |3 A
cn = DriverManager.getConnection( url, sUsr, sPwd );7 U+ W: ^" P% A
' B5 b+ o/ s$ o6 V, `
8. PostgreSQL
, |- o% j0 \3 i& A+ T Class.forName( "org.postgresql.Driver" );! V. k" g+ ?: d% o8 T- f
cn = DriverManager.getConnection( "jdbc:postgresql://MyDbComputerNameOrIP/myDatabaseName", sUsr, sPwd );6 i# o) r0 W! i) U9 f6 p) G
9 j4 `' _* K3 I4 C
9. Sybase6 N5 a) m4 s1 f& s
Class.forName( "com.sybase.jdbc2.jdbc.SybDriver" );/ D6 ?6 r9 s, T* n& k
cn = DriverManager.getConnection( "jdbc:sybase:Tds:MyDbComputerNameOrIP:2638", sUsr, sPwd );0 ~1 T# M0 F7 e6 r5 K' e! Q+ K; i
//(Default-Username/Password: "dba"/"sql")
/ W$ J3 \! Y" z% ~
3 L. ^6 w5 J& r. [( G
+ s9 o3 ]# z. \( B. X6 N. I, s D |
|