1.连接SqlServer2000 msbase.jar msutil.jar mssqlserver.jar
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
String url = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=tempdb";
2.连接SqlServer2005 sqljdbc.jar
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String url = "jdbc:sqlserver://localhost:1433;DatabaseName=tempdb";
3.MySQL() mysql-connector-java-5.0.7-bin.jar
Class.forName( "com.mysql.jdbc.Driver" );
cn = DriverManager.getConnection("jdbc:mysql://MyDbComputerNameOrIP:3306/myDatabaseName", sUsr, sPwd );
4.Oracle(
//注意把oracle下的classes12.zip 改名为classes12.jar,然后拷贝到tomcat的common/lib下
Class.forName("oracle.jdbc.driver.OracleDriver");
5.使用jtds连接SQLServer2000() jtds-1.2.jar
Class.forName( "net.sourceforge.jtds.jdbc.Driver" );
cn = DriverManager.getConnection
("jdbc:jtds:sqlserver://MyDbComputerNameOrIP:1433/数据库名", sUsr, sPwd );
6.ODBC
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
Connection cn = DriverManager.getConnection( "jdbc:odbc:数据源名", sUsr, sPwd );
7.DB2
Class.forName("Com.ibm.db2.jdbc.app.DB2Driver");
String url="jdbc:db2://192.9.200.108:6789/数据库名"
cn = DriverManager.getConnection( url, sUsr, sPwd );
8.PostgreSQL(
Class.forName( "org.postgresql.Driver" );
cn = DriverManager.getConnection("jdbc:postgresql://MyDbComputerNameOrIP/myDatabaseName", sUsr, sPwd );
9.Sybase(
Class.forName( "com.sybase.jdbc2.jdbc.SybDriver" );
cn = DriverManager.getConnection( "jdbc:sybase:Tds:MyDbComputerNameOrIP:2638", sUsr, sPwd );
//(Default-Username/Password: "dba"/"sql")
阅读(430) | 评论(0) | 转发(0) |