db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James Adams <monoco...@gmail.com>
Subject Not creating database and executeQuery() errors with Hibernate+Spring+Atomikos
Date Tue, 02 Dec 2008 21:13:35 GMT

I am trying to use a Derby database (either embedded or network server) for
some DAO tests and I am getting the following errors:

Derby running Embedded: 

    (Spring configuration:)

    <bean id="dataSource"
          class="com.atomikos.jdbc.SimpleDataSourceBean"
          init-method="init"
          destroy-method="close">
        <property name="uniqueResourceName"><value>XADBMS</value></property>
        <!-- set the underlying driver class to use-->
        <property
name="xaDataSourceClassName"><value>org.apache.derby.jdbc.EmbeddedXADataSource40</value></property>
        <property name="xaDataSourceProperties">
           
<value>databaseName=lifecycle;createDatabase=create;shutdownDatabase=shutdown</value>
        </property>
        <property
name="exclusiveConnectionMode"><value>true</value></property>
        <property name="connectionPoolSize" value="10"/>
    </bean>

ERROR:

Error creating bean with name 'dataSource' defined in URL
[file:/C:/dev/projects/lifecycle/build/classes/applicationContext.xml]:
Invocation of init method failed; nested exception is java.sql.SQLException:
Database 'lifecycle' not found.
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'dataSource' defined in URL
[file:/C:/dev/projects/lifecycle/build/classes/applicationContext.xml]:
Invocation of init method failed; nested exception is java.sql.SQLException:
Database 'lifecycle' not found.
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1362)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:540)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:485)
        at java.security.AccessController.doPrivileged(Native Method)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:455)
        at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
        at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:169)
        at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
        at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:170)
        at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:413)
        at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:735)
        at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:369)
        at
org.springframework.test.AbstractSingleSpringContextTests.createApplicationContext(AbstractSingleSpringContextTests.java:199)
        at
org.springframework.test.AbstractSingleSpringContextTests.loadContextLocations(AbstractSingleSpringContextTests.java:179)
        at
org.springframework.test.AbstractSingleSpringContextTests.loadContext(AbstractSingleSpringContextTests.java:158)
        at
org.springframework.test.AbstractSpringContextTests.getContext(AbstractSpringContextTests.java:105)
        at
org.springframework.test.AbstractSingleSpringContextTests.setUp(AbstractSingleSpringContextTests.java:87)
        at
org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:69)
Caused by: java.sql.SQLException: Database 'lifecycle' not found.
        at
org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown
Source)
        at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown
Source)
        at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown
Source)
        at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown
Source)
        at
org.apache.derby.impl.jdbc.EmbedConnection.newSQLException(Unknown Source)
        at
org.apache.derby.impl.jdbc.EmbedConnection.handleDBNotFound(Unknown Source)
        at org.apache.derby.impl.jdbc.EmbedConnection.<init>(Unknown Source)
        at org.apache.derby.impl.jdbc.EmbedConnection30.<init>(Unknown
Source)
        at org.apache.derby.impl.jdbc.EmbedConnection40.<init>(Unknown
Source)
        at org.apache.derby.jdbc.Driver40.getNewEmbedConnection(Unknown
Source)
        at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source)
        at org.apache.derby.jdbc.EmbeddedDataSource.getConnection(Unknown
Source)
        at org.apache.derby.jdbc.EmbeddedDataSource.getConnection(Unknown
Source)
        at
org.apache.derby.jdbc.EmbeddedXADataSource.setupResourceAdapter(Unknown
Source)
        at
org.apache.derby.jdbc.EmbeddedXADataSource.getXAConnection(Unknown Source)
        at
com.atomikos.jdbc.XAConnectionFactory.getPooledConnection(XAConnectionFactory.java:309)
        at com.atomikos.jdbc.ConnectionPool.<init>(ConnectionPool.java:78)
        at
com.atomikos.jdbc.JtaDataSourceImp.<init>(JtaDataSourceImp.java:269)
        at
com.atomikos.jdbc.SimpleDataSourceBean.checkSetup(SimpleDataSourceBean.java:241)
        at
com.atomikos.jdbc.SimpleDataSourceBean.init(SimpleDataSourceBean.java:284)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1427)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1396)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1359)
Caused by: java.sql.SQLException: Database 'lifecycle' not found.
        at
org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown
Source)
        at
org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown
Source)




When I have Derby running as a Network Server:

    (Spring configuration:)

    <bean id="dataSource"
          class="com.atomikos.jdbc.SimpleDataSourceBean"
          init-method="init"
          destroy-method="close">
        <property name="uniqueResourceName"><value>XADBMS</value></property>
        <!-- set the underlying driver class to use-->
        <property
name="xaDataSourceClassName"><value>org.apache.derby.jdbc.ClientXADataSource40</value></property>-->
        <property name="xaDataSourceProperties">
           
<value>user=root;password=monocongo;serverName=127.0.0.1;portNumber=1527;databaseName=lifecycle;createDatabase=create</value>
        </property>
        <property
name="exclusiveConnectionMode"><value>true</value></property>
        <property name="connectionPoolSize" value="10"/>
    </bean>


ERROR:

org.springframework.jdbc.UncategorizedSQLException: Hibernate operation:
could not execute query; uncategorized SQLException for SQL [select
servicehos0_.SERVICE_HOST_ID as SERVICE1_6_,
servicehos0_.CONNECTION_DETAILS_ID as CONNECTION11_6_,
servicehos0_.DESCRIPTION as DESCRIPT2_6_, servicehos0_.HARDWARE_CONFIG_ID as
HARDWARE12_6_, servicehos0_.HARDWARE_DESCRIPTION as HARDWARE3_6_,
servicehos0_.HOST_STATUS as HOST4_6_, servicehos0_.HOST_TYPE as HOST5_6_,
servicehos0_.LOM_MAC_ADDRESS as LOM6_6_, servicehos0_.LOM_SWITCH_PORT as
LOM7_6_, servicehos0_.MAC_ADDRESS as MAC8_6_, servicehos0_.PHYSICAL_LOCATION
as PHYSICAL9_6_, servicehos0_.SWITCH_PORT as SWITCH10_6_ from SERVICE_HOST
servicehos0_]; SQL state [XJ207]; error code [20000]; executeQuery method
can not be used for update.; nested exception is java.sql.SQLException:
executeQuery method can not be used for update.
        at
org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.translate(SQLStateSQLExceptionTranslator.java:121)
        at
org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.translate(SQLErrorCodeSQLExceptionTranslator.java:322)
        at
org.springframework.orm.hibernate3.HibernateAccessor.convertJdbcAccessException(HibernateAccessor.java:424)
        at
org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:410)
        at
org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:378)
        at
org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:847)
        at
org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:839)
        at
com.sun.network.lifecycle.persistence.dao.GenericDaoHibernateImpl.findAll(GenericDaoHibernateImpl.java:106)
        at
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:301)
        at
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
        at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
        at
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
        at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
        at
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
        at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
        at
org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
        at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
        at
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
        at $Proxy22.findAll(Unknown Source)


I was having different issues with Atomikos and JTA before when using MySQL,
insufficient XA support, which is why I'm trying to use Derby.  Is Derby's
XA support also incomplete, or in some way crippled because of this
executeQuery() issue? I saw something in some release notes showing that a
previous issue with executeQuery() being resolved (now returning correct
return values) in the latest Derby release.  Is this not the case, or is
what I'm dealing with above unrelated?

Thanks in advance for any suggestions regarding this issue.

--James
-- 
View this message in context: http://www.nabble.com/Not-creating-database-and-executeQuery%28%29-errors-with-Hibernate%2BSpring%2BAtomikos-tp20801068p20801068.html
Sent from the Apache Derby Users mailing list archive at Nabble.com.


Mime
View raw message