国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計 > 正文

JDBC連接數(shù)據(jù)庫經(jīng)驗集萃

2019-11-17 06:12:26
字體:
供稿:網(wǎng)友
java數(shù)據(jù)庫連接(JDBC)由一組用 Java 編程語言編寫的類和接口組成。JDBC 為工具/數(shù)據(jù)庫開發(fā)人員提供了一個標(biāo)準(zhǔn)的 API,使他們能夠用純Java API 來編寫數(shù)據(jù)庫應(yīng)用程序。然而各個開發(fā)商的接口并不完全相同,所以開發(fā)環(huán)境的變化會帶來一定的配置變化。本文主要集合了不同數(shù)據(jù)庫的連接方式。

  一、連接各種數(shù)據(jù)庫方式速查表

  下面羅列了各種數(shù)據(jù)庫使用JDBC連接的方式,可以作為一個手冊使用。

  1、Oracle8/8i/9i數(shù)據(jù)庫(thin模式)

Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
String url="jdbc:oracle:thin:@localhost:1521:orcl"; //orcl為數(shù)據(jù)庫的SID
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"; //sample為你的數(shù)據(jù)庫名
String user="admin";
String password="";
Connection conn= DriverManager.getConnection(url,user,password);
  3、Sql Server7.0/2000數(shù)據(jù)庫

Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=mydb";
//mydb為數(shù)據(jù)庫
String user="sa";
String password="";
Connection conn= DriverManager.getConnection(url,user,password);
  4、Sybase數(shù)據(jù)庫

Class.forName("com.sybase.jdbc.SybDriver").newInstance();
String url =" jdbc:sybase:Tds:localhost:5007/myDB";//myDB為你的數(shù)據(jù)庫名
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://123.45.67.89:1533/myDB:INFORMIXSERVER=myserver;
user=testuser;password=testpassword"; //myDB為數(shù)據(jù)庫名
Connection conn= DriverManager.getConnection(url);
  6、MySQL數(shù)據(jù)庫

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

Class.forName("org.postgresql.Driver").newInstance();
String url ="jdbc:postgresql://localhost/myDB" //myDB為數(shù)據(jù)庫名
String user="myuser";
String password="mypassword";
Connection conn= DriverManager.getConnection(url,user,password);
  8、access數(shù)據(jù)庫直連用ODBC的



發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 大渡口区| 襄城县| 澄江县| 兴宁市| 沙田区| 鲁山县| 合阳县| 巴里| 聊城市| 偃师市| 连江县| 天津市| 巫山县| 曲水县| 珲春市| 托克托县| 兰州市| 金寨县| 邹平县| 庄河市| 禹城市| 平和县| 连城县| 西盟| 许昌市| 肇州县| 平江县| 巴彦县| 会宁县| 雷州市| 灵武市| 乌拉特前旗| 孝义市| 苍溪县| 布拖县| 古蔺县| 柳河县| 阿瓦提县| 桑日县| 唐山市| 辽阳市|