日期:2014-05-16 浏览次数:20648 次
1. MySQL
?? Class.forName("org.gjt.mm.mysql.Driver").newInstance();???
?? String? url? ="jdbc:mysql://localhost/myDB?user=soft&password=soft1234&useUnicode=?true&characterEncoding=8859_1"???
?? Connection? conn=? DriverManager.getConnection(url,user,password);?
?
2. ORACLE
?? Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();???
?? String? url="jdbc:oracle:thin:@localhost:1521:orcl";???
?? //orcl为数据库的SID???
?? String? user="test";???
?? String? password="test";???
?? Connection? conn=? DriverManager.getConnection(url,user,password);?
?
3. DB2
?? Class.forName("com.ibm.db2.jdbc.app.DB2Driver? ").newInstance();???
?? String? url="jdbc:db2://localhost:5000/sample";????
?? String? user="admin";????
?? String? password="";???
?? Connection? conn=? DriverManager.getConnection(url,user,password);?
?
4. Microsoft SQLServer
?
??????? (SqlServer 2000)
??????????? Class.forName( "com.microsoft.jdbc.sqlserver.SQLServerDriver" );
??????????? conn = DriverManager.getConnection( "jdbc:microsoft:sqlserver://localhost:1433;databaseName=pubs", sUsr, sPwd );
?
? ??????(SqlServer 2005)
??????????? Class.forName( "com.microsoft.sqlserver.jdbc.SQLServerDriver" );
??????????? conn = DriverManager.getConnection( "jdbc:sqlserver://localhost:1433;databaseName=pubs", sUsr, sPwd );
?