日期:2014-05-16  浏览次数:20523 次

Hibernate连接ACCESS数据库

1、在lib目录下导入2个jar包

Access_JDBC30.jar

hibernate.jar


2、Hibernate添加数据源


Driver templat:

Driver name: access

Connection URL:jdbc:access:///G:/ACCESS/test1.mdb

Driver JARs :Access_JDBC30.jar


3、Hibernate数据源配置?
<property name="dialect">com.hxtt.support.hibernate.HxttAccessDialect</property>

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
          "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<!-- Generated by MyEclipse Hibernate Tools.                   -->
<hibernate-configuration>

<session-factory>
	<property name="connection.url">
		jdbc:access:///G:/ACCESS/test1.mdb
	</property>
	<property name="myeclipse.connection.profile">access</property>
	<property name="connection.driver_class">
		com.hxtt.sql.access.AccessDriver
	</property>
	<property name="show_sql">true</property>
	<property name="connection.username"></property>
	<property name="connection.password"></property>
	<property name="hibernate.dialect">
		com.hxtt.support.hibernate.HxttAccessDialect
	</property>
	<property name="dialect">com.hxtt.support.hibernate.HxttAccessDialect</property>
	<mapping resource="com/jsw/hibernate/entity/TUser.hbm.xml" />

</session-factory>

</hibernate-configuration>

?