I am to connect to MS Access database in my application that uses grails.
I am in the process o开发者_开发知识库f configuring my Datasource.groovy, but am not sure of the dialect to be used. Any help?
EDIT: Thoughts on this question???
Thanks!
Grails uses Hibernate under the hood, and it seems you need some efforts to make Hibernate to work with Access. Unfortunately, Access is not supported officially by Hibernate. So I recommend changing into an officially supported database(MySQL, Postgres, MS SQL...)
But if you insist using Access, you can take the Hibernate dialect for Access from this question. It will take some effort to make things work, and remember, this stuff maynot be maintained in the future.
Here is an example of the xml syntax:
<?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="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>
<property name="hibernate.connection.driver_class">sun.jdbc.odbc.JdbcOdbcDriver</property>
<property name="hibernate.connection.url">jdbc:odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=d:/temp/Database9.accdb</property>
<property name="connection.username"></property>
<property name="connection.password"></property>
<property name="connection.pool_size">1</property>
<property name="current_session_context_class">thread</property>
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<property name="show_sql">true</property>
<property name="hbm2ddl.auto">update</property>
<mapping resource="com/prj/domain/prj.hbm.xml"/>
</session-factory> </hibernate-configuration>
精彩评论