MySql数据库的hibernate连接设置,在hibernate.cfg.xml文件中
<hibernate-configuration>
<session-factory>
<property name="show_sql">true</property>
<property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>
<property name="jdbc.fetch_size">50</property>
<property name="jdbc.batch_size">30</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost/dbname?characterEncoding=gb2312</property>
<property name="connection.username">root</property>
<property name="connection.password">root</property>
<mapping resource="com/amigo/pojo/User.hbm.xml"/>
<mapping resource="com/amigo/pojo/Org.hbm.xml"/>
</session-factory>
</hibernate-configuration>
mysql-connector-java-5.0.4-bin.jar
2. Sql Server连接配置Sql Server数据库的hibernate在配置文件中配置。
连接部分
<property name="connection.driver_class">net.sourceforge.jtds.jdbc.Driver</property>
<property
name="connection.url">jdbc:jtds:sqlserver://localhost:1433;DatabaseName=dbname</property>
<property name="connection.username">sa</property>
<property name="connection.password"></property>
jtds-1.2.jar
3. Oracle连接配置Oracler数据库的hibernate在配置文件中配置。
连接部分
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="connection.url">jdbc:oracle:thin:@localhost:1521:dbname</property>
<property name="connection.username">test</property>
<property name="connection.password">test</property>
ojdbc14.jar
4. DB2连接配置DB2数据库的hibernate在配置文件中配置。
<property name="connection.driver_class"> com.ibm.db2.jdbc.app.DB2Driver</property>
<property
name="connection.url"> jdbc:db2://localhost:5000/sample </property> //sample为数据库名
<property name="connection.username">admin</property>
<property name="connection.password"></property>
db2jcc.jar
5.sybase连接配置
<property name="connection.driver_class">com.sybase.jdbc.SybDrive</property>
<property
name="connection.url"> jdbc:sybase:Tds:localhost:5007/myDB</property> ;//myDB为数据库名
<property name="connection.username">userid</property>
<property name="connection.password">user_password</property>
jconn3.jar
6. informix连接配置<property name="connection.driver_class">com.informix.jdbc.IfxDrive</property>
<property
name="connection.url">jdbc:informix-sqli://123.45.67.89:1533/myDB:INFORMIXSERVER=myserver </property> ;
<property name="connection.username">testuser</property>
<property name="connection.password">testpassword</property>
ifxjdbc.jar
<property name="connection.driver_class">org.postgresql.Driver</property>
<property
name="connection.url">jdbc:postgresql://localhost/myDB</property>;//myDB为数据库名
<property name="connection.username">myuser</property>
<property name="connection.password">mypassword</property>
postgresql-8.1-405.jdbc3
8.access连接配置
<property name="connection.driver_class">sun.jdbc.odbc.JdbcOdbcDriver</property>
<property
name="connection.url">jdbc:odbc:Driver={MicroSoft..Access..Driver(*.mdb)};DBQ="+application.getRealPath("/Data/ReportDemo.mdb")</property> ;
<property name="connection.username">myuser</property>
<property name="connection.password">mypassword</property>
access数据库的驱动为:sun.jdbc.odbc.JdbcOdbcDriver或者是com.hxtt.sql.access.AccessDriver
jar包:Access_JDBC30.jar
Hibernate SQL方言 (hibernate.dialect) 大全:
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 |