users@glassfish.java.net

Having problem executing query against AS/400

From: <glassfish_at_javadesktop.org>
Date: Fri, 09 Nov 2007 10:24:32 PST

I'm not sure what else I can do, I just can't get a JPA query to execute without getting this error message:

[code]
Hibernate:
    /* select
        ac
    from
        AnimalClass ac */ select
            animalclas0_.ABCLASS as ABCLASS0_,
            animalclas0_.CLASDESC as CLASDESC0_
        from
            ABCLASP animalclas0_
SQL Error: -518, SQLState: 07003
[SQL0518] Prepared statement STMT0001 not found.
EJB5018: An exception was thrown during an ejb invocation on [AnimalBean]
javax.ejb.EJBException
        at com.sun.ejb.containers.BaseContainer.processSystemException(BaseContainer.java:3869)
        at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:3769)
        at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:3571)
        at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1354)
        at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1316)
        at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:205)
        at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:127)
        at $Proxy33.getAllClasses(Unknown Source)
        at com.myapp.servlet.DataTest.processRequest(DataTest.java:38)
        at com.myapp.servlet.DataTest.doGet(DataTest.java:59)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:718)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
        at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:411)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:317)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
        at com.myapp.exec.PortletFilter.doFilter(PortletFilter.java:35)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
        at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:288)
        at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:271)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:202)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
        at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:206)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:150)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
        at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:270)
        at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:637)
        at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:568)
        at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:813)
        at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:339)
        at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:261)
        at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:212)
        at com.sun.enterprise.web.portunif.PortUnificationPipeline$PUTask.doTask(PortUnificationPipeline.java:361)
        at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
        at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)

............................................................

Caused by: org.hibernate.exception.SQLGrammarException: could not execute query
        at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
        at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
        at org.hibernate.loader.Loader.doList(Loader.java:2223)
        at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
        at org.hibernate.loader.Loader.list(Loader.java:2099)
        at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:378)
        at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
        at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
        at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
        at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
        at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:66)
        ... 51 more
Caused by: java.sql.SQLException: [SQL0518] Prepared statement STMT0001 not found.
        at com.ibm.as400.access.JDError.throwSQLException(JDError.java:520)
        at com.ibm.as400.access.AS400JDBCStatement.commonExecute(AS400JDBCStatement.java:822)
        at com.ibm.as400.access.AS400JDBCPreparedStatement.executeQuery(AS400JDBCPreparedStatement.java:1081)
        at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)
        at org.hibernate.loader.Loader.getResultSet(Loader.java:1787)
        at org.hibernate.loader.Loader.doQuery(Loader.java:674)
        at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
        at org.hibernate.loader.Loader.doList(Loader.java:2220)
        ... 59 more
[/code]

Here's my sun-resources.xml for the JDBC pool:

[code]
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE resources PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 Resource Definitions //EN" "http://www.sun.com/software/appserver/dtds/sun-resources_1_3.dtd">
<resources>
  <jdbc-resource enabled="true" jndi-name="MyAS400DS" object-type="user" pool-name="jdbc_myas400Pool"/>
  <jdbc-connection-pool
    allow-non-component-callers="false"
    associate-with-thread="false"
    connection-creation-retry-attempts="0"
    connection-creation-retry-interval-in-seconds="10"
    connection-leak-reclaim="false"
    connection-leak-timeout-in-seconds="0"
    connection-validation-method="auto-commit"
    datasource-classname="com.ibm.as400.access.AS400JDBCDataSource"
    fail-all-connections="false"
    idle-timeout-in-seconds="300"
    is-connection-validation-required="false"
    is-isolation-level-guaranteed="true"
    lazy-connection-association="false"
    lazy-connection-enlistment="false"
    match-connections="false"
    max-connection-usage-count="0"
    max-pool-size="32"
    max-wait-time-in-millis="60000"
    name="jdbc_myas400Pool"
    non-transactional-connections="false"
    pool-resize-quantity="2"
    res-type="javax.sql.DataSource"
    statement-timeout-in-seconds="-1"
    steady-pool-size="8"
    validate-atmost-once-period-in-seconds="0"
    wrap-jdbc-objects="false">
    <property name="User" value="MYUSER"/>
    <property name="Password" value="MYPASS"/>
    <property name="URL" value="jdbc:as400://servername"/>
    <property name="driverClass" value="com.ibm.as400.access.AS400JDBCDriver"/>
    <property name="serverName" value="AB400"/>
    <property name="libraries" value="MYLIBVALUE"/>
  </jdbc-connection-pool>
</resources>
[/code]

It pings just fine and I even get the expected feedback when deploying to Glassfish v2:

[code]
deployed with moduleid = MyApp
Processing PersistenceUnitInfo [
        name: MyAppPU
        ...]
found EJB3 Entity bean: com.myapp.model.AnimalClass
Binding entity from annotated class: com.myapp.model.AnimalClass
Bind entity com.myapp.model.AnimalClass on table ABCLASP
Hibernate Validator not found: ignoring
Hibernate Validator not found: ignoring
Initializing connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider
Using provided datasource
RDBMS: DB2 UDB for AS/400, version: 05.02.0000 V5R2m0
JDBC driver: AS/400 Toolbox for Java JDBC Driver, version: 5.0
Using dialect: org.hibernate.dialect.DB2400Dialect
Transaction strategy: org.hibernate.ejb.transaction.JoinableCMTTransactionFactory
instantiating TransactionManagerLookup: org.hibernate.transaction.SunONETransactionManagerLookup
instantiated TransactionManagerLookup
Automatic flush during beforeCompletion(): disabled
Automatic session close at end of transaction: disabled
Scrollable result sets: enabled
JDBC3 getGeneratedKeys(): enabled
Connection release mode: auto
Maximum outer join fetch depth: 1
Default batch fetch size: 1
Generate SQL with comments: enabled
Order SQL updates by primary key: disabled
Order SQL inserts for batching: disabled
Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
Using ASTQueryTranslatorFactory
Query language substitutions: {}
JPA-QL strict compliance: enabled
Second-level cache: enabled
Query cache: disabled
Cache provider: org.hibernate.cache.NoCacheProvider
Optimize cache for minimal puts: disabled
Structured second-level cache entries: disabled
Echoing all SQL to stdout
Statistics: disabled
Deleted entity synthetic identifier rollback: disabled
Default entity-mode: pojo
Named query checking : enabled
building session factory
Not binding factory to JNDI, no JNDI name configured
JNDI InitialContext properties:{}
naming.bind
LDR5010: All ejb(s) of [PortletsExecutive] loaded successfully!
[/code]

...any ideas on how I can make this work?

Thanks!
[Message sent by forum member 'zambizzi' (zambizzi)]

http://forums.java.net/jive/thread.jspa?messageID=244798