数据库连接URL和驱动

来源:互联网 发布:unity3d局域网联机 编辑:程序博客网 时间:2024/05/16 10:20

URL:   
1.Oracle:"jdbc:oracle:thin:@localhost:1521:orcl"
2.Access:"jdbc:odbc:HANFENG"
3.SQL Server:"jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=pubs","sa",""
4.DB2:"jdbc:db2://localhost:5000/sample"
5.Informix:"jdbc:informix-sqli://123.45.67.89:1533/testDB:INFORMIXSERVER=myserver"
6.Sybase:"jdbc:sybase:Tds:localhost:5007/tsdata"
7.MySQL:"jdbc:mysql://localho st/softforum?user=soft&password=soft1234&useUnicode=true&characte rEncoding=8859_1"
驱动器:
Oracle: oracle.jdbc.driver.OracleDriver
Access: sun.jdbc.odbc.JdbcOdbcDriver
SQL Server: com.microsoft.jdbc.sqlserver.SQLServerDriver
DB2: com.ibm.db2.jdbc.app.DB2Driver 
Informix: com.informix.jdbc.IfxDriver
Sybase: com.sybase.jdbc.SybDriver
MySQL: org.gjt.mm.mysql.Driver
com.mysql.jdbc.Driver   
 

Hibernate 不同数据库的连接及SQL方言

RDBMS 方言DB2org.hibernate.dialect.DB2DialectDB2 AS/400org.hibernate.dialect.DB2400DialectDB2 OS390org.hibernate.dialect.DB2390DialectPostgreSQLorg.hibernate.dialect.PostgreSQLDialectMySQLorg.hibernate.dialect.MySQLDialectMySQL with InnoDBorg.hibernate.dialect.MySQLInnoDBDialectMySQL with MyISAMorg.hibernate.dialect.MySQLMyISAMDialectOracle (any version)org.hibernate.dialect.OracleDialectOracle 9i/10gorg.hibernate.dialect.Oracle9DialectSybaseorg.hibernate.dialect.SybaseDialectSybase Anywhereorg.hibernate.dialect.SybaseAnywhereDialectMicrosoft SQL Serverorg.hibernate.dialect.SQLServerDialectSAP DBorg.hibernate.dialect.SAPDBDialectInformixorg.hibernate.dialect.InformixDialectHypersonicSQLorg.hibernate.dialect.HSQLDialectIngresorg.hibernate.dialect.IngresDialectProgressorg.hibernate.dialect.ProgressDialectMckoi SQLorg.hibernate.dialect.MckoiDialectInterbaseorg.hibernate.dialect.InterbaseDialectPointbaseorg.hibernate.dialect.PointbaseDialectFrontBaseorg.hibernate.dialect.FrontbaseDialectFirebirdorg.hibernate.dialect.FirebirdDialect

 

 

在hibernate.cfg.xml中配置如下

  <property name="hibernate.connection.url">jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=pubs</property>
  <property name="hibernate.connection.username">sa</property>
  <property name="hibernate.connection.password">221383</property>
  <property name="hibernate.connection.driver_class">com.microsoft.jdbc.sqlserver.SQLServerDriver</property>
  <property name="dialect">org.hibernate.dialect.SQLServerDialect</property>

 

在hibernate.properties中配置如下

## Oracle

hibernate.dialect org.hibernate.dialect.OracleDialect
hibernate.dialect org.hibernate.dialect.Oracle9Dialect
hibernate.connection.driver_class oracle.jdbc.driver.OracleDriver
hibernate.connection.username ora
hibernate.connection.password ora
hibernate.connection.url jdbc:oracle:thin:@localhost:1521:orcl

原创粉丝点击