现在想把开发完成的程序,弄个简化版,以前是Java Hibernate oracle的,现在想用 access 。网上找了些资料,弄了好久没有成功,现在可以了,共享一下hibernate.cft.xml:
<?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"> <hibernate-configuration> <session-factory> <property name="connection.url"> jdbc:access:///data/DB.mdb </property> <property name="myeclipse.connection.profile">access</property> <property name="connection.driver_class"> com.hxtt.sql.access.AccessDriver </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> <!-- validate 加载 时,验证创建数据库表结构 create 每次加载 ,重新创建数据库表结构,这就是导致数据库表数据丢失的原因。 create-drop 加载 时创建,退出是删除表结构 update 加载hibernate自动更新数据库结构 --> <property name="hibernate.hbm2ddl.auto">update</property> <!-- 让 自动管理会话环境 --> <property name="current_session_context_class">thread</property> <!--显示查询语句 --> <property name="hibernate.show_sql">true</property> <!--格式化SQL --> <property name="hibernate.format_sql">true</property> <!--提示信息 --> <property name="use_sql_comments">true</property> <!--配置映射文件 --> <mapping resource="db/hibernate/mapping/xx.hbm.xml"></mapping> </session-factory> </hibernate-configuration>
jdbc:access:///data/DB.mdb 配置相对路径方法。