-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 
Author Message
 Post subject: Using MS Access in Hibernate3?
PostPosted: Thu Aug 11, 2005 12:36 am 
Senior
Senior

Joined: Wed Dec 17, 2003 4:24 am
Posts: 188
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

3.0.5:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping package="lyo.hotmail.domain">
<class
name="Author"
table="AUTHOR"
>
<id
name="authorId"
type="string"
column="AUTHOR_ID"
>
<generator class="uuid.hex"/>
</id>

<property
name="authorSex"
column="AUTHOR_SEX"
type="string"
not-null="false"
length="1"
/>
<property
name="authorMemo"
column="AUTHOR_MEMO"
type="string"
not-null="false"
length="19"
/>
<property
name="authorEmail"
column="AUTHOR_EMAIL"
type="string"
not-null="false"
length="100"
/>


<property
name="authorName"
column="AUTHOR_NAME"
type="string"
not-null="false"
length="40"
/>

<property
name="authorAge"
column="AUTHOR_AGE"
type="integer"
not-null="false"
length="11"
/>

<set
inverse="true"
lazy="true"
name="articleSet"
>
<key column="AUTHOR_ID" />
<one-to-many class="Article" />
</set>
</class>
</hibernate-mapping>
:


public List getAuthors() throws DataAccessException {
// TODO Auto-generated method stub
return this.getHibernateTemplate().find("from Author a");
}


2005-08-11 12:30:07,695 [main] INFO org.springframework.jdbc.support.SQLErrorCodesFactory - SQLErrorCodes loaded: [DB2, HSQL, MS-SQL, MySQL, Oracle, Informix, PostgreSQL, Sybase]
Hibernate: select author0_.AUTHOR_ID as AUTHOR1_, author0_.AUTHOR_SEX as AUTHOR2_1_, author0_.AUTHOR_MEMO as AUTHOR3_1_, author0_.AUTHOR_EMAIL as AUTHOR4_1_, author0_.AUTHOR_NAME as AUTHOR5_1_, author0_.AUTHOR_AGE as AUTHOR6_1_ from AUTHOR author0_
2005-08-11 12:30:08,736 [main] WARN org.hibernate.jdbc.AbstractBatcher - exception clearing maxRows/queryTimeout
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]optional function not implement
at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.SQLGetStmtOption(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcStatement.getStmtOption(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcStatement.getQueryTimeout(Unknown Source)
at org.apache.commons.dbcp.DelegatingStatement.getQueryTimeout(DelegatingStatement.java:243)
at org.hibernate.jdbc.AbstractBatcher.closeQueryStatement(AbstractBatcher.java:205)
at org.hibernate.jdbc.AbstractBatcher.closeQueryStatement(AbstractBatcher.java:143)
at org.hibernate.loader.Loader.doQuery(Loader.java:433)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)
at org.hibernate.loader.Loader.doList(Loader.java:1593)
at org.hibernate.loader.Loader.list(Loader.java:1577)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:395)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:271)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:844)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
at org.springframework.orm.hibernate3.HibernateTemplate$29.doInHibernate(HibernateTemplate.java:748)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:310)
at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:739)
at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:731)
at lyo.hotmail.service.BaseDAOImpl.getAuthors(BaseDAOImpl.java:29)
at lyo.hotmail.dao.TestAuthorDAOImpl.testGetAuthors(TestAuthorDAOImpl.java:43)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)
Get Author: [lyo.hotmail.domain.Author@19ec4ed]
Hibernate: select author0_.AUTHOR_ID as AUTHOR1_, author0_.AUTHOR_SEX as AUTHOR2_1_, author0_.AUTHOR_MEMO as AUTHOR3_1_, author0_.AUTHOR_EMAIL as AUTHOR4_1_, author0_.AUTHOR_NAME as AUTHOR5_1_, author0_.AUTHOR_AGE as AUTHOR6_1_ from AUTHOR author0_
2005-08-11 12:30:09,077 [main] WARN org.hibernate.jdbc.AbstractBatcher - exception clearing maxRows/queryTimeout
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]optional function not implement
at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.SQLGetStmtOption(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcStatement.getStmtOption(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcStatement.getQueryTimeout(Unknown Source)
at org.apache.commons.dbcp.DelegatingStatement.getQueryTimeout(DelegatingStatement.java:243)
at org.hibernate.jdbc.AbstractBatcher.closeQueryStatement(AbstractBatcher.java:205)
at org.hibernate.jdbc.AbstractBatcher.closeQueryStatement(AbstractBatcher.java:143)
at org.hibernate.loader.Loader.doQuery(Loader.java:433)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)
at org.hibernate.loader.Loader.doList(Loader.java:1593)
at org.hibernate.loader.Loader.list(Loader.java:1577)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:395)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:271)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:844)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
at org.springframework.orm.hibernate3.HibernateTemplate$29.doInHibernate(HibernateTemplate.java:748)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:310)
at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:739)
at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:731)
at lyo.hotmail.service.BaseDAOImpl.getAuthors(BaseDAOImpl.java:29)
at lyo.hotmail.dao.TestAuthorDAOImpl.testGetAuthors(TestAuthorDAOImpl.java:44)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)


Access 2002 (Office XP):

Hibernate: select author0_.AUTHOR_ID as AUTHOR1_, author0_.AUTHOR_SEX as AUTHOR2_1_, author0_.AUTHOR_MEMO as AUTHOR3_1_, author0_.AUTHOR_EMAIL as AUTHOR4_1_, author0_.AUTHOR_NAME as AUTHOR5_1_, author0_.AUTHOR_AGE as AUTHOR6_1_ from AUTHOR author0_

INFO:


Hi everyone:

I want to use MS Access with Hibernate3,but when I run a simple JUnit test,it throw exception:

Code:
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]optional function not implement
.My config file is:
Code:
<beans>
<bean id="MyDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <!-- results in a setDriverClassName(String) call -->
        <property name="driverClassName">
            <value>sun.jdbc.odbc.JdbcOdbcDriver</value>
        </property>
        <property name="url">
            <value>jdbc:odbc:Accessforum</value>
        </property>
        <property name="username">
            <value>user</value>
        </property>
      <property name="password">
            <value></value>
        </property>
      
      <property name="defaultAutoCommit">
            <value>false</value>
        </property>
      
    </bean>
   
   <!--
<bean id="MyJNDIDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
  <property name="jndiName">
    <value>jdbc/mysql</value>
  </property>
</bean>
-->
<bean id="MySessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
   <property name="mappingResources">
      <list>
       
        <value>lyo/hotmail/domain/Article.hbm.xml</value>
      <value>lyo/hotmail/domain/Author.hbm.xml</value>
      </list>
   </property>
   <property name="hibernateProperties">
      <props>
        [color=red][b]<prop key="hibernate.dialect">org.hibernate.dialect.GenericDialect</prop>[/b][/color]        <prop key="hibernate.query.substitutions">true=1 false=0</prop>
        <prop key="hibernate.show_sql">true</prop>
        <prop key="hibernate.use_outer_join">false</prop>
      </props>
   </property>
   <property name="dataSource"><ref bean="MyDataSource"/></property>
</bean>
<bean id="baseDao" class="lyo.hotmail.service.BaseDAOImpl">
   <property name="sessionFactory">
      <ref bean="MySessionFactory"/>
   </property>
</bean>
</beans>

There is no access Dialect in hibernate implement,so I use GenericDialect.
Couldn't I use Hibernate with MS Access? Could Hibernate could work with jdbc-odbc driver? Thks!

_________________
You are not alone...


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 11, 2005 2:03 am 
Expert
Expert

Joined: Thu Sep 04, 2003 8:23 am
Posts: 368
This is not a Dialect problem.
If you look at line 205 in AbstractBacther as it is mentionned in the stacktrace you'll see that Hibernate tries to do setQueryTimeout(0) but this method is not implemented in access (I don't know if this is different with another jdbc driver for access).

Note that this is only a warning, not an error. Access is not in the supported database list. You can also have problem with joins (if you fetch more than one join at a time). You can try to use it but nothing is guaranteed[/quote]

_________________
Seb
(Please don't forget to give credits if you found this answer useful :)


Top
 Profile  
 
 Post subject: :(
PostPosted: Thu Aug 11, 2005 6:53 am 
Senior
Senior

Joined: Wed Dec 17, 2003 4:24 am
Posts: 188
scesbron wrote:
This is not a Dialect problem.
If you look at line 205 in AbstractBacther as it is mentionned in the stacktrace you'll see that Hibernate tries to do setQueryTimeout(0) but this method is not implemented in access (I don't know if this is different with another jdbc driver for access).

Note that this is only a warning, not an error. Access is not in the supported database list. You can also have problem with joins (if you fetch more than one join at a time). You can try to use it but nothing is guaranteed
[/quote]

No, It is an Exception! Not only a warn ;-(

When an exception happen, java JVM will allocate some memory(also Stack) to the exception. So it is not a good idea.

You mean that jdbc-odbc driver don't support setQueryTimeout method? But it is a simplest query ;-(

_________________
You are not alone...


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 11, 2005 7:04 am 
Expert
Expert

Joined: Thu Sep 04, 2003 8:23 am
Posts: 368
I know that hibernate throws an Exception. If you don't want it to you may recompile a version without this exception but it may leads to problem as in the code there is a comment that says this is a workaround for pool common problem.

This is not a simple query but a feature that database and database driver may or may not implement. I don't know if this is a driver specific problem or an access limitation.

You may try this http://www.easysoft.com/support/kb/kb00563.html. Then hibernate may not throw an exception

_________________
Seb
(Please don't forget to give credits if you found this answer useful :)


Top
 Profile  
 
 Post subject: :(
PostPosted: Thu Aug 11, 2005 7:24 am 
Senior
Senior

Joined: Wed Dec 17, 2003 4:24 am
Posts: 188
scesbron wrote:
I know that hibernate throws an Exception. If you don't want it to you may recompile a version without this exception but it may leads to problem as in the code there is a comment that says this is a workaround for pool common problem.

This is not a simple query but a feature that database and database driver may or may not implement. I don't know if this is a driver specific problem or an access limitation.

You may try this http://www.easysoft.com/support/kb/kb00563.html. Then hibernate may not throw an exception


Thank you for your reply. But the page you told me seems have some problem:
Code:
404 - PAGE NOT FOUND
Due to the re-development of the Easysoft Website, the page you are looking for may have moved or no longer exists.

If you have reached this page via a bookmark in your browser, you will need to update it. The Easysoft website has undergone a complete re-development and as a result, your old bookmarks will now be out of date.

If you reached this page by following a link on the Easysoft website, the webmaster has automatically been informed and will investigate the problem.

_________________
You are not alone...


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 11, 2005 7:34 am 
Expert
Expert

Joined: Thu Sep 04, 2003 8:23 am
Posts: 368
here is the content
Quote:
How can I make my application/servlet engine progress beyond calling setQueryTimeOut when connecting to Access?

Article : 00563
Last Reviewed : 19th July 2005
Revision : 1

Access does not allow you to set the query timeout and the Statement.setQueryTimeout(int) call throws an exception with SQL State SC100.

By setting the registry key to "y":

HKEY_LOCAL_MACHINE\
SOFTWARE\
Easysoft JDBC-ODBC Bridge\
Configuration\
System\
settings\
S1C00

it will downgrade the SQLException for SQLState S1C00 to an SQLWarning, thus allowing the application to progress.


The main page seems to be : http://www.easysoft.com/support/kb/prod ... bc_bridge/

_________________
Seb
(Please don't forget to give credits if you found this answer useful :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.