db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kristian Waagan <Kristian.Waa...@Sun.COM>
Subject Re: Not creating database and executeQuery() errors with Hibernate+Spring+Atomikos
Date Wed, 03 Dec 2008 08:35:39 GMT
James Adams wrote:
> 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>
>
>   
Hi James,

Just wondering why both createDatabase and shutdownDatabase are 
specified in the configuration.
Since you're getting the database not found exception, Derby can't be 
creating the database in the first place.

> 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
>
>   
[ snip - stack trace ]
>
>
> 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
>   
[ snip - stack trace ]

This doesn't make sense to me, at least I can't see the query doing any 
update...
Are there any stack traces or error messages in derby.log?

By the way, this exception is only thrown from Statement:
        if (executeType == executeQueryMethod__ && sqlMode == isUpdate__) {
            throw new SqlException(agent_.logWriter_,
                new 
ClientMessageId(SQLState.CANT_USE_EXEC_QUERY_FOR_UPDATE));
        }

So why is isUpdate__ true in this case?
Does this happen also when you disable connection pooling?


Regards,
-- 
Kristian

> 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
>   


Mime
View raw message