<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連接各種數據庫的實例

    此文中的代碼主要列出連接數據庫的關鍵代碼,其他訪問數據庫代碼省略

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

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

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

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

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

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

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

    偶參照上面寫了一個跟sql連接的頁面,有不少錯誤。 搞得比較郁悶,不過今天剛剛弄好了,要是有需要的就看看偶寫的《jsp連接sql server 2000 完整版》呵呵,或許能讓你少走不少彎路哦,因為我是搞了2天才完全曉得哪里會出問題的哦

    posted on 2006-03-16 11:34 MEYE 閱讀(212) 評論(0)  編輯  收藏 所屬分類: JAVA
    主站蜘蛛池模板: 国产精品亚洲一区二区麻豆| 久久青青草原亚洲av无码| 亚洲天堂一区二区| 99re6在线精品免费观看| 久久久久噜噜噜亚洲熟女综合| 一区二区三区在线免费观看视频 | 亚洲婷婷天堂在线综合| 8x8×在线永久免费视频| 久久亚洲精品中文字幕| 91精品国产免费| 亚洲午夜久久久精品电影院| 无码一区二区三区AV免费| 亚洲人成77777在线观看网| 女人毛片a级大学毛片免费| 朝桐光亚洲专区在线中文字幕 | 久久精品免费全国观看国产| 久久国产亚洲精品| 国产美女精品久久久久久久免费 | 免费成人在线视频观看| 亚洲网站在线免费观看| 18禁成年无码免费网站无遮挡| 亚洲国产无线乱码在线观看 | 又爽又黄无遮挡高清免费视频 | 亚洲精品制服丝袜四区| 久久久久久精品成人免费图片| 成人亚洲国产va天堂| 亚洲第一福利网站在线观看| 国产日韩一区二区三免费高清| 日韩亚洲AV无码一区二区不卡| 好男人视频在线观看免费看片| 一出一进一爽一粗一大视频免费的| 亚洲AV无码第一区二区三区| 91成人免费在线视频| 十八禁的黄污污免费网站| 亚洲色图在线观看| 国产麻豆剧传媒精品国产免费| 国产一级a毛一级a看免费视频| 亚洲免费福利视频| 久久久久亚洲精品无码网址| 日韩中文字幕精品免费一区| 永久免费精品影视网站|