<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 189,comments - 115,trackbacks - 0
    Java連接各種數(shù)據(jù)庫(kù)的實(shí)例

    此文中的代碼主要列出連接數(shù)據(jù)庫(kù)的關(guān)鍵代碼,其他訪問(wèn)數(shù)據(jù)庫(kù)代碼省略

    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&useUnicode=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);

    偶參照上面寫(xiě)了一個(gè)跟sql連接的頁(yè)面,有不少錯(cuò)誤。 搞得比較郁悶,不過(guò)今天剛剛弄好了,要是有需要的就看看偶寫(xiě)的《jsp連接sql server 2000 完整版》呵呵,或許能讓你少走不少?gòu)澛放叮驗(yàn)槲沂歉懔?天才完全曉得哪里會(huì)出問(wèn)題的哦

    posted on 2006-03-16 11:34 MEYE 閱讀(212) 評(píng)論(0)  編輯  收藏 所屬分類(lèi): JAVA
    主站蜘蛛池模板: 在线aⅴ亚洲中文字幕| 久久久久亚洲av无码专区蜜芽| 亚洲一区在线免费观看| 久久免费看黄a级毛片 | 黄网站色视频免费观看45分钟| 日本高清色本免费现在观看| 亚洲熟妇无码一区二区三区导航| 青青青国产免费一夜七次郎| 国产亚洲欧美在线观看| mm1313亚洲精品国产| 国产精品免费视频观看拍拍| 亚洲日韩精品一区二区三区 | 亚洲国产成人久久精品动漫| 日韩在线永久免费播放| 亚洲人成网站18禁止久久影院 | 毛片免费全部播放一级| 色www免费视频| 亚洲人成精品久久久久| 中文字幕免费在线| 亚洲色欲色欱wwW在线| 亚洲成a人片在线观看老师| 叮咚影视在线观看免费完整版| 亚洲精品天天影视综合网| av免费不卡国产观看| 亚洲av永久无码天堂网| 亚洲人成网站在线观看播放| 2020因为爱你带字幕免费观看全集| 一本天堂ⅴ无码亚洲道久久| 亚洲国产精品成人| 一级毛片**不卡免费播| 亚洲国产成人精品无码区花野真一| 亚洲精品国产成人影院| 99国产精品免费视频观看| 亚洲国产无线乱码在线观看| 亚洲中久无码永久在线观看同 | 又粗又大又硬又爽的免费视频 | 性xxxxx大片免费视频| 亚洲性色精品一区二区在线| 久久久久国产成人精品亚洲午夜 | 成年大片免费视频播放一级| 91在线精品亚洲一区二区|