sqlserver默认端口号为:1433
URL:"jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=dbname"
DRIVERNAME:"com.microsoft.jdbc.sqlserver.SQLServerDriver";
mysql 默认端口号为:3306
URL:jdbc:mysql://localhost:3306/test? user=root&password=&useUnicode=true&characterEncoding=gbk
DRIVERNAME:"com.mysql.jdbc.Driver";
oracle 默认端口号为:1521
URL:"jdbc:oracle:thin:@localhost:1521:orcl ";
DRIVERNAME:"oracle.jdbc.driver.OracleDriver";
ODBC:
URL----"jdbc:odbc:Mydatabase","sa", ""
driver--sun.jdbc.odbc.JdbcOdbcDriver
1.SQLServer:
URL----
jdbc:microsoft:sqlserver://localhost:1433;databasename=pubs
driver--com.microsoft.jdbc.sqlserver.SQLServerDriver
2.Oracle:
URL----oracle:oci8:@newer
URL----jdbc:oracle:thin:@10.0.0.200:1521:newer (jdbc:oracle:thin:@[ip]:[port]:[sid])
driver--oracle.jdbc.driver.OracleDriver
3.mysql
url---- jdbc:mysql://127.0.0.1:3306/mysql
driver--org.gjt.mm.mysql.Driver
or
driver=com.mysql.jdbc.Driver
url=jdbc:mysql://127.0.0.1:3306/DBName?user=root&password=1
4.DB2
url-----jdbc:db2://localhost:5000/sample
driver--com.ibm.db2.jdbc.app.DB2Driver
5.使用jtds包访问
Driver---net.sourceforge.jtds.jdbc.Driver
URL------jdbc:jtds:<server_type>://<server>[:<port>][/<database>][;<property>=<value>[;...]]
URL例如:jdbc:jtds:sqlserver://localhost:1433;DatabaseName=CHDB
或者: jdbc:jtds:sqlserver://localhost:1433/CHDB;user=sa;password=sa
----------------------------
Connection con;
Statement stmt;
ResultSet rs;
Class.forName("net.sourceforge.jtds.jdbc.Driver");
DriverManager.registerDriver(newnet.sourceforge.jtds.jdbc.Driver());
String dbUrl="jdbc:jtds:sqlserver://localhost:1433/j2eeone;user=sa;password=caicaibao";
//String dbUser="j2ee";
//String dbPwd="j2ee";
con=java.sql.DriverManager.getConnection(dbUrl);
stmt=con.createStatement();
rs=stmt.executeQuery("SELECTid,name,title,priceFROMbooks");