posts - 38,  comments - 22,  trackbacks - 0
          數(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的 Class.forName("sun.jdbc.odbc.JdbcOdbcDriver") ; String url="jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb)};DBQ="+application.getRealPath("/Data/ReportDemo.mdb"); Connection conn = DriverManager.getConnection(url,"",""); Statement stmtNew=conn.createStatement() ;
          轉(zhuǎn)貼
          posted on 2006-12-08 10:09 aaabbb 閱讀(263) 評論(0)  編輯  收藏 所屬分類: DataBase

          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 巴东县| 旺苍县| 肇东市| 上蔡县| 法库县| 渝中区| 贞丰县| 上虞市| 德兴市| 惠州市| 通山县| 荥阳市| 淮安市| 抚远县| 隆德县| 天全县| 华坪县| 密山市| 德昌县| 临邑县| 渭南市| 闵行区| 古浪县| 密山市| 灵台县| 通辽市| 阿坝县| 莎车县| 北安市| 富阳市| 开江县| 靖边县| 灵丘县| 闵行区| 明溪县| 锡林浩特市| 基隆市| 金塔县| 郴州市| 垦利县| 湖州市|