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

首頁 > 編程 > Java > 正文

使用Java程序連接各,種數(shù)據(jù)庫的方法介紹

2019-11-02 15:18:29
字體:
供稿:網(wǎng)友

   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();

  //或者Class.forName("com.mysql.jdbc.Driver");

  String url =&qu

無憂無慮電影網(wǎng)[www.aikan.tv/special/wuyouwulvdianyingwang/]
ot;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);

  

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 都匀市| 大丰市| 静安区| 重庆市| 雷波县| 新营市| 溧阳市| 晋江市| 尼勒克县| 隆德县| 织金县| 辽阳县| 沐川县| 永泰县| 舟曲县| 女性| 临安市| 蒙城县| 金坛市| 康乐县| 府谷县| 卓尼县| 仁化县| 饶平县| 西峡县| 南通市| 陆良县| 武冈市| 嫩江县| 元谋县| 梁山县| 湟中县| 淮南市| 孝昌县| 本溪市| 辽阳市| 阿坝| 娄烦县| 炉霍县| 乾安县| 上高县|