- 1、Oracle8/8i/9i數(shù)據(jù)庫(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);
-
- 2、DB2數(shù)據(jù)庫
- 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);
-
- 3、Sql Server7.0/2000/2005數(shù)據(jù)庫
- /*使用的是4.0驅動,此JAR包名稱為sqljdbc4.jar,文件大小為 524 KB (537,303 字節(jié)) ,文件修改時間為2010年4月19日,10:12:00*/
- public static void main(String[] args) {
String driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"; String url="jdbc:sqlserver://192.168.1.113:3329;DatabaseName=kinsys"; String username="sa"; String password=""; Connection con = null; try{ Class.forName(driverClassName); con = DriverManager.getConnection(url, username, password); System.out.println("Connection successed."); }catch(Exception e){ e.printStackTrace(); } }
-
-
- 4、Sybase數(shù)據(jù)庫
- Class.forName("com.sybase.jdbc.SybDriver").newInstance();
- String url =" jdbc:sybase:Tds:localhost:5007/myDB";
-
- Properties sysProps = System.getProperties();
- SysProps.put("user","userid");
- SysProps.put("password","user_password");
- Connection conn= DriverManager.getConnection(url, SysProps);
-
- 5、Informix數(shù)據(jù)庫
- Class.forName("com.informix.jdbc.IfxDriver").newInstance();
- String url =
- "jdbc:informix-sqli:
- user=testuser;password=testpassword";
-
- Connection conn= DriverManager.getConnection(url);
-
- 6、MySQL數(shù)據(jù)庫
- /*org.gjt.mm.mysql.Driver是早期的驅動名稱,后來就改名為com.mysql.jdbc.Driver,現(xiàn)在一般都推薦使用 com.mysql.jdbc.Driver。在最新版本的mysql jdbc驅動中,為了保持對老版本的兼容,仍然保留了org.gjt.mm.mysql.Driver,但是實際上 org.gjt.mm.mysql.Driver中調用了com.mysql.jdbc.Driver,因此現(xiàn)在這兩個驅動沒有什么區(qū)別。*/
- Class.forName("com.mysql.jdbc.Driver").newInstance();
- String url ="jdbc:mysql://localhost/myDB?user=soft&password=soft1234&useUnicode=true&characterEncoding=8859_1" //解決中文顯示問題
-
- Connection conn= DriverManager.getConnection(url);
-
- 7、PostgreSQL數(shù)據(jù)庫
- Class.forName("org.postgresql.Driver").newInstance();
- String url ="jdbc:postgresql://localhost/myDB"
-
- String user="myuser";
- String password="mypassword";
- Connection conn= DriverManager.getConnection(url,user,password);
|
|
CALENDER
| 日 | 一 | 二 | 三 | 四 | 五 | 六 |
---|
27 | 28 | 29 | 30 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
|
常用鏈接
留言簿
隨筆分類
隨筆檔案
文章分類
文章檔案
新聞檔案
相冊
搜索
最新評論

閱讀排行榜
評論排行榜
Powered By: 博客園 模板提供:滬江博客
|