数据库的连接技术 JDBC 连接集锦
1.Oracle8/8i/9i数据库(thin模式)?
????
- Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();??? ??
-
????String?url="jdbc:oracle:thin:@localhost:1521:orcl";???
-
????String?user="test";??? ??
-
????String?password="test";??? ??
- ????Connection?conn=?DriverManager.getConnection(url,user,password);????
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);
2.DB2数据库?
???
- Class.forName("com.ibm.db2.jdbc.app.DB2Driver?").newInstance();??? ??
-
????String?url="jdbc:db2://localhost:5000/sample";?//sample为你的数据库名??? ??
-
????String?user="admin";??? ??
-
????String?password="";??? ??
- ????Connection?conn=?DriverManager.getConnection(url,user,password);????
Class.forName("com.ibm.db2.jdbc.app.DB2Driver ").newInstance();
String url="jdbc:db2://localhost:5000/sample"; //sample为你的数据库名
String user="admin";
String password="";
Connection conn= DriverManager.getConnection(url,user,password);
3.Sql Server7.0/2000数据库?
??
- Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();??? ??
-
???String?url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=mydb";??? ??
-
?????
-
???String?user="sa";??? ??
-
???String?password="";??? ??
- ???Connection?conn=?DriverManager.getConnection(url,user,password);????<