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(""
).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:
user
=testuser;password
=testpassword
"; //mydb為資料庫名
connection conn
=drivermanager.getconnection(url);
6、mysql資料庫
class.forname(
"org.gjt.mm.mysql.driver
").newinstance();
//或者class.forname("com.mysql.jdbc.driver");
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資料庫直連用odbc的
class.forname(
"sun.jdbc.odbc.jdbcodbcdriver
") ;
string url="
jdbc:odbc:driver=;dbq="+
"/data/reportdemo.mdb
");
connection conn
=drivermanager.getconnection(url,"",
"");
Java資料庫連線字串
1 oracle8 8i 9i資料庫 thin模式 class.forname oracle.jdbc.driver.oracledriver newinstance string url jdbc oracle thin localhost 1521 orcl orcl為資料庫的sid strin...
Java連線RAC資料庫字串
jdbc oracle thin description address list address protocol tcp host 192.168.0.231 port 1521 address protocol tcp host 192.168.0.232 port 1521 load bal...
資料庫連線字串 EXCEL 連線字串
odbc 標準driver driverid 790 dbq c myexcel.xls defaultdir c mypath sql表示式 select from sheet1 例如 在excel工作表名稱後面跟 字元並且使用 將其括起來。ole db 標準provider microsoft....