Sung in Blog

                     一些技術(shù)文章 & 一些生活雜碎

          1、Oracle8/8i/9i數(shù)據(jù)庫(kù)(thin模式)
          Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
          String url="jdbc:oracle:thin:@localhost:1521:orcl";
          //orcl為數(shù)據(jù)庫(kù)的SID
          String user="test";
          String password="test";
          Connection conn= DriverManager.getConnection(url,user,password);

          2、DB2數(shù)據(jù)庫(kù)
          Class.forName("com.ibm.db2.jdbc.app.DB2Driver ").newInstance();
          String url="jdbc:db2://localhost:5000/sample";
          //sample為你的數(shù)據(jù)庫(kù)名
          String user="admin";
          String password="";
          Connection conn= DriverManager.getConnection(url,user,password);

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

          4、Sybase數(shù)據(jù)庫(kù)
          Class.forName("com.sybase.jdbc.SybDriver").newInstance();
          String url =" jdbc:sybase:Tds:localhost:5007/myDB";
          //myDB為你的數(shù)據(jù)庫(kù)名
          Properties sysProps = System.getProperties();
          SysProps.put("user","userid");
          SysProps.put("password","user_password");
          Connection conn= DriverManager.getConnection(url, SysProps);

          5、Informix數(shù)據(jù)庫(kù)
          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ù)庫(kù)名
          Connection conn= DriverManager.getConnection(url);

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

          7、PostgreSQL數(shù)據(jù)庫(kù)
          Class.forName("org.postgresql.Driver").newInstance();
          String url ="jdbc:postgresql://localhost/myDB"
          //myDB為數(shù)據(jù)庫(kù)名
          String user="myuser";
          String password="mypassword";
          Connection conn= DriverManager.getConnection(url,user,password);

          1、Oracle8/8i/9i數(shù)據(jù)庫(kù)(thin模式)
          Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
          String url="jdbc:oracle:thin:@localhost:1521:orcl";
          //orcl為數(shù)據(jù)庫(kù)的SID
          String user="test";
          String password="test";
          Connection conn= DriverManager.getConnection(url,user,password);

          2、DB2數(shù)據(jù)庫(kù)
          Class.forName("com.ibm.db2.jdbc.app.DB2Driver ").newInstance();
          String url="jdbc:db2://localhost:5000/sample";
          //sample為你的數(shù)據(jù)庫(kù)名
          String user="admin";
          String password="";
          Connection conn= DriverManager.getConnection(url,user,password);

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

          4、Sybase數(shù)據(jù)庫(kù)
          Class.forName("com.sybase.jdbc.SybDriver").newInstance();
          String url =" jdbc:sybase:Tds:localhost:5007/myDB";
          //myDB為你的數(shù)據(jù)庫(kù)名
          Properties sysProps = System.getProperties();
          SysProps.put("user","userid");
          SysProps.put("password","user_password");
          Connection conn= DriverManager.getConnection(url, SysProps);

          5、Informix數(shù)據(jù)庫(kù)
          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ù)庫(kù)名
          Connection conn= DriverManager.getConnection(url);

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

          7、PostgreSQL數(shù)據(jù)庫(kù)
          Class.forName("org.postgresql.Driver").newInstance();
          String url ="jdbc:postgresql://localhost/myDB"
          //myDB為數(shù)據(jù)庫(kù)名
          String user="myuser";
          String password="mypassword";
          Connection conn= DriverManager.getConnection(url,user,password);

          ]]>
          posted on 2005-09-01 16:43 Sung 閱讀(110) 評(píng)論(0)  編輯  收藏 所屬分類: Java
          主站蜘蛛池模板: 呼玛县| 双峰县| 申扎县| 仙桃市| 辰溪县| 华蓥市| 晋江市| 秀山| 永定县| 澳门| 黔江区| 云梦县| 海口市| 措勤县| 绥德县| 双江| 大港区| 长丰县| 漠河县| 清远市| 衡阳市| 开封市| 黑河市| 汤原县| 陇南市| 普宁市| 东港市| 靖州| 天峨县| 凭祥市| 社会| 衡阳县| 库车县| 嘉峪关市| 丹巴县| 图木舒克市| 甘谷县| 肇东市| 苍山县| 景洪市| 平塘县|