自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Java技巧:Java連接數(shù)據(jù)庫技巧全攻略

數(shù)據(jù)庫
編者在本文將主要為大家介紹Java與Oracle、DB2、Sql Server、Sybase、MySQL、PostgreSQL等數(shù)據(jù)庫連接的方法。

編者在本文將主要為大家介紹Java與Oracle、DB2、Sql Server、Sybase、MySQL、PostgreSQL等數(shù)據(jù)庫連接的方法。

1、Oracle數(shù)據(jù)庫

  1. Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();  
  2.  
  3.   String url="jdbc:oracle:thin:@localhost:1521:orcl";  
  4.  
  5.   //orcl為數(shù)據(jù)庫的SID  
  6.  
  7.   String user="test";  
  8.  
  9.   String password="test";  
  10.  
  11.   Connection conn= DriverManager.getConnection(url,user,password);  
  12.  

  #p# 

 2、DB2數(shù)據(jù)庫

  1.   Class.forName("com.ibm.db2.jdbc.app.DB2Driver ").newInstance();  
  2.  
  3.   String url="jdbc:db2://localhost:5000/sample";  
  4.  
  5.   //sample為你的數(shù)據(jù)庫名  
  6.  
  7.   String user="admin";  
  8.  
  9.   String password="";  
  10.  
  11.   Connection conn= DriverManager.getConnection(url,user,password);  
  12.  

  #p#

3、Sql Server數(shù)據(jù)庫

  1.   Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();  
  2.  
  3.   String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=mydb";  
  4.  
  5.   //mydb為數(shù)據(jù)庫  
  6.  
  7.   String user="sa";  
  8.  
  9.   String password="";  
  10.  
  11.   Connection conn= DriverManager.getConnection(url,user,password);  
  12.  

 #p#

 4、Sybase數(shù)據(jù)庫

  1.   Class.forName("com.sybase.jdbc.SybDriver").newInstance();  
  2.  
  3.   String url =" jdbc:sybase:Tds:localhost:5007/myDB";  
  4.  
  5.   //myDB為你的數(shù)據(jù)庫名  
  6.  
  7.   Properties sysProps = System.getProperties();  
  8.  
  9.   SysProps.put("user","userid");  
  10.  
  11.   SysProps.put("password","user_password");  
  12.  
  13.   Connection conn= DriverManager.getConnection(url, SysProps);  
  14.  

 #p#

 5、MySQL數(shù)據(jù)庫

  1.   Class.forName("org.gjt.mm.mysql.Driver").newInstance();  
  2.  
  3.   String url ="jdbc:mysql://localhost/myDB?user=soft&password=soft1234&useUnicode=true&characterEncoding=8859_1" 
  4.  
  5.   //myDB為數(shù)據(jù)庫名  
  6.  
  7.   Connection conn= DriverManager.getConnection(url);  
  8.  

 #p#

 6、PostgreSQL數(shù)據(jù)庫

  1.   Class.forName("org.postgresql.Driver").newInstance();  
  2.  
  3.   String url ="jdbc:postgresql://localhost/myDB" 
  4.  
  5.   //myDB為數(shù)據(jù)庫名  
  6.  
  7.   String user="myuser";  
  8.  
  9.   String password="mypassword";  
  10.  
  11.   Connection conn= DriverManager.getConnection(url,user,password);  
責(zé)任編輯:艾婧 來源: it168網(wǎng)站原創(chuàng)
相關(guān)推薦

2015-03-04 13:53:33

MySQL數(shù)據(jù)庫優(yōu)化SQL優(yōu)化

2023-10-13 19:42:00

2011-07-19 20:36:56

2009-12-15 18:03:46

Ruby連接數(shù)據(jù)庫

2010-08-10 09:53:47

DB2數(shù)據(jù)庫補丁

2010-01-07 17:24:12

VB.NET連接數(shù)據(jù)庫

2025-01-21 08:10:00

2024-11-26 10:01:25

2024-02-22 09:25:09

Python字典推導(dǎo)式開發(fā)

2010-05-26 11:22:08

2023-10-12 07:29:24

MySQL分頁數(shù)據(jù)量

2009-07-17 15:34:37

Java Swing連接數(shù)據(jù)庫

2024-05-07 09:01:21

Queue 模塊Python線程安全隊列

2013-06-08 11:13:00

Android開發(fā)XML解析

2013-04-15 10:48:16

Xcode ARC詳解iOS ARC使用

2010-04-23 14:04:23

Oracle日期操作

2011-03-10 11:17:03

數(shù)據(jù)庫設(shè)計技巧

2014-03-19 17:22:33

2009-12-14 14:32:38

動態(tài)路由配置

2009-10-19 15:20:01

家庭綜合布線
點贊
收藏

51CTO技術(shù)棧公眾號