java 驱动

Posted on 2009-10-26 22:49 无很 阅读(390) 评论(0)  编辑  收藏 所属分类: IBatisHibernate
JDBC-ODBC桥接:
//加载jdbc-odbc驱动程序
class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
//通过数据源连接:
String url ="jdbc:odbc:YourDSN";
String user= "sa";
String password ="";
Connection conn = DriverManager.getConnection(url,user,password);


Oracle;
Class.forName("oracle.jdbc.driver.OracleDriver");
String url="jdbc:oracle:thin:@localhost:1521:oraDB";
Connection conn = DriverManager.getConnection(url,"system","manager");


SqlServer:
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
//然后要设置连接
String url="jdbc:microsoft:sqlserver://yourserver:port;DatabaseName=yourdatabase";
Connection conn= DriverManager.getConnection(url,"uername","password");

MySql:
Class.forName("org.gjt.mm.mysql.Driver");
String url ="jdbc:mysql://localhost/testDB?user=sa&password=&useUnicode=true&characterEncoding=8859_1"
//testDB为你的数据库名
Connection conn= DriverManager.getConnection(url);

Sybase:
Class.forName("com.sybase.jdbc2.jdbc.SybDriver");
DriverManager.getConnection("jdbc:sybase:Tds:yourserver:2638?ServiceName=database",user,password);

Postgresql:
Class.forName("org.postgresql.Driver");
Connection con=DriverManager.getConnection("jdbc:postgresql://host:port/database","user","password");

DB2:
Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");



String url="jdbc:db2://yourserver:6789/SAMPLE";
DriverManager.getConnection(url,sUsr,sPwd);

Informix:
Class.forName("com.informix.jdbc.IfxDriver");
String url = "jdbc:informix-sqli://123.45.67.89:1533/myDB:INFORMIXSERVER=myserver;
user=testuser;password=testpassword";
//myDB为数据库名
Connection conn= DriverManager.getConnection(url,user,password);

只有注册用户登录后才能发表评论。


网站导航: