java jdbc url 不同数据库



1.Oracle数据库

Class.forName("oracle.jdbc.driver.OracleDriver" ).newInstance() ;

String url = "jdbc : oracle :thin: @ localhost:1521rcle " ;

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/testDB";

String user = "admin";

String password = "test";

Connection conn = DriverManager.getConnection ( url, user, password ) ;



3.SQL Server数据库

Class.forName( "com.microsoft.jdbc.sqlserver.SQLServerDriver" ) .newInstance() ;

String url = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=testDB ";

String user = "sa";

String password = "test";

Connection conn = DriverManager.getConnection(url, user, password ) ;



4. Sybase数据库

Class.forName( "com.sybase.jdbc.SybDriver" ).newInstance();

String url = "jdbc:sybase:Tds:localhost:5007/testDB";

Properties sysProps = System.getProperties() ;

sysProps.put("user", "userid";

sysProps.put("password", "user_password" );

Connection conn = DriverManager.getConnection(url, sysProps ) ;



5.Informix数据库

Class.forName("com.infoxmix.jdbc.IfxDriver".newInstance();

String url = "jdbc:infoxmix-sqli://localhost:1533/testDB:INFORMIXSERVER=myserver;user=testuser;password=testpassword";

Connection conn = DriverManager.getConnection(url);

6.MySQL数据库



Class.forName("org.gjt.mm.mysql.Driver".newInstance();

String url = "jdbc:mysql://localhost/testDB?user=testuser&password=testpassword&useUnicode=true&characterEncoding=GB2312";

Connection conn = DriverManager.getConnection(url);



7.PostgreSQL数据库

Class.forName("org.postgresql.Driver".newInstance();

String url = "jdbc:postgresql://localhost/testDB";

String user = "myuser";

String password = "test";

Connection conn = DriverManager.getConnection(url, user, password ) ;



实Hibernate本身是个独立的框架,它不需要任何web server或application server的支持。然而,大多数的Hibernate入门介绍都加入了很多非Hibernate的东西,比如: Tomcat, Eclipse, Log4J,Struts, XDoclet, 甚至JBoss。这容易让人产生Hibernate复杂难懂的误解,特别是打击了初学者的积极性。

在这篇文章将不涉及Eclipse, log4j, Struts, Tomcat, XDoclet,和JBoss。本文的目的是演示一下Hibernate的安装过程以及最基本的功能,从而给初学者一个低得不能再低的入门门槛。


下载文件 

你需要Java SDK、 Hibernate包、Ant包、和JDBC Driver。

1、Hibernate包下载地址:
http://prdownloads.sourceforge.n ... =date&sort=desc 

2、Ant包下载地址:
http://apache.130th.net/ant/binaries/apache-ant-1.6.1-bin.zip 

3、 JDBC Driver要根据你用的database来定,一般database官方网站上都会有。Hibernate支持常用的database,比如 MySQL, Oracle, PostgreSQL, 和MS-SQL Server。这些数据库都有JDBC Driver: 

Oracle JDBC Driver下载地址(下载前必须同意Oracle协议书)
http://otn.oracle.com/software/h ... tdocs/jdbc9201.html 

MySQL JDBC Driver下载地址
http://dev.mysql.com/downloads/connector/j/3.0.html 

PostgreSQL JDBC Driver下载地址
http://jdbc.postgresql.org/download.html 

MS-SQL Server JDBC Driver下载地址
http://www.microsoft.com/downloa ... &displaylang=en

你可能感兴趣的:(java jdbc url 不同数据库)