Posted on 2009-05-26 18:07
hanwei 阅读(88)
评论(0) 编辑 收藏
1、JDBC连接Oracle (classes14.jar 该驱动可在oracle安装的目录中找到)
Class.forName( "oracle.jdbc.driver.OracleDriver" );
cn = DriverManager.getConnection( "jdbc:oracle:thin:@192.168.1.120:1521:orcl", "test", "123");
2、JDBC连接MySQL
Class.forName( "org.gjt.mm.mysql.Driver" );
cn = DriverManager.getConnection( "jdbc:mysql://192.168.1.120:3306/test", "root", "123");
3、JDBC连接Microsoft SQLServer
Class.forName( "com.microsoft.jdbc.sqlserver.SQLServerDriver" );
cn = DriverManager.getConnection( "jdbc:microsoft:sqlserver://192.168.1.120:1433;databaseName=test", "admin", "123");
4、JDBC连接ODBC (sDsn为DSN数据源)
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
Connection cn = DriverManager.getConnection( "jdbc:odbc:" + sDsn, sUsr, sPwd );