posts - 4,comments - 30,trackbacks - 0

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

          ??? 8、Access數據庫

          ??? Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

          ??? String dburl ="jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=Mobile.mdb";//此為NO-DSN方式

          ??? //String dburl ="jdbc:odbc:odbcName";//此為ODBC連接方式

          ??? Connection conn=DriverManager.getConnection(dburl);

          posted on 2007-08-24 11:08 蠻哥♂楓 閱讀(252) 評論(0)  編輯  收藏 所屬分類: Java
          主站蜘蛛池模板: 淮北市| 肇庆市| 弥渡县| 安庆市| 九龙城区| 潜山县| 墨江| 富裕县| 崇州市| 和平区| 临安市| 当涂县| 荣成市| 漳州市| 胶州市| 长泰县| 五台县| 建水县| 石柱| 丰都县| 慈溪市| 哈巴河县| 成都市| 金昌市| 九江市| 聂拉木县| 汉源县| 如东县| 秭归县| 若羌县| 德州市| 南江县| 陵水| 梅河口市| 远安县| 阳江市| 澄城县| 禄劝| 行唐县| 张家川| 张北县|