各种数据库连接的url和驱动器
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 | 方言 |
---|---|
DB2 | org.hibernate.dialect.DB2Dialect |
DB2 AS/400 | org.hibernate.dialect.DB2400Dialect |
DB2 OS390 | org.hibernate.dialect.DB2390Dialect |
PostgreSQL | org.hibernate.dialect.PostgreSQLDialect |
MySQL | org.hibernate.dialect.MySQLDialect |
MySQL with InnoDB | org.hibernate.dialect.MySQLInnoDBDialect |
MySQL with MyISAM | org.hibernate.dialect.MySQLMyISAMDialect |
Oracle (any version) | org.hibernate.dialect.OracleDialect |
Oracle 9i/10g | org.hibernate.dialect.Oracle9Dialect |
Sybase | org.hibernate.dialect.SybaseDialect |
Sybase Anywhere | org.hibernate.dialect.SybaseAnywhereDialect |
Microsoft SQL Server | org.hibernate.dialect.SQLServerDialect |
SAP DB | org.hibernate.dialect.SAPDBDialect |
Informix | org.hibernate.dialect.InformixDialect |
HypersonicSQL | org.hibernate.dialect.HSQLDialect |
Ingres | org.hibernate.dialect.IngresDialect |
Progress | org.hibernate.dialect.ProgressDialect |
Mckoi SQL | org.hibernate.dialect.MckoiDialect |
Interbase | org.hibernate.dialect.InterbaseDialect |
Pointbase | org.hibernate.dialect.PointbaseDialect |
FrontBase | org.hibernate.dialect.FrontbaseDialect |
Firebird | org.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