java java-ee nullpointerexception hsqldb jbatch

java - HSQLDB prepareStatement("SET SCHEMA?") Error



java-ee nullpointerexception (1)

Estoy escribiendo un servicio Jbatch que requiere una conexión con un HSQLDB pero en cierto punto me arroja una NullPointerException (y algunas SQLExceptions / PersistenceExceptions). Depuración Descubrí que en la clase JDBCPersistenceManagerImpl.java establece SCHEMA en?, Pero parece que en HSQLDB no es compatible.

private void setSchemaOnConnection(Connection connection) throws SQLException { logger.finest("Entering " + CLASSNAME +".setSchemaOnConnection()"); if (!"Oracle".equals(connection.getMetaData().getDatabaseProductName())) { PreparedStatement ps = null; ps = connection.prepareStatement("SET SCHEMA ?"); -->ps = NullPointerException ps.setString(1, schema); ps.executeUpdate(); ps.close(); } logger.finest("Exiting " + CLASSNAME +".setSchemaOnConnection()"); }

¿Alguna idea sobre cómo solucionarlo? Ya he probado otro databse (H2 db) pero el problema es el mismo.

Esta es la traza de la pila completa:

javax.batch.operations.JobStartException: com.ibm.jbatch.container.exception.PersistenceException: java.sql.SQLException: java.lang.NullPointerException java.lang.NullPointerException at com.ibm.jbatch.container.api.impl.JobOperatorImpl.start(JobOperatorImpl.java:92) at factory.jf.privacy.service.loggedareasfilter.batch.AzzaTest.testBatchChunkException(AzzaTest.java:22) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:119) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) Caused by: com.ibm.jbatch.container.exception.PersistenceException: java.sql.SQLException: java.lang.NullPointerException java.lang.NullPointerException at com.ibm.jbatch.container.services.impl.JDBCPersistenceManagerImpl.createJobInstance(JDBCPersistenceManagerImpl.java:1682) at com.ibm.jbatch.container.jobinstance.JobExecutionHelper.getNewJobInstance(JobExecutionHelper.java:89) at com.ibm.jbatch.container.jobinstance.JobExecutionHelper.startJob(JobExecutionHelper.java:120) at com.ibm.jbatch.container.impl.BatchKernelImpl.startJob(BatchKernelImpl.java:124) at com.ibm.jbatch.container.api.impl.JobOperatorImpl.startInternal(JobOperatorImpl.java:123) at com.ibm.jbatch.container.api.impl.JobOperatorImpl.start(JobOperatorImpl.java:88) ... 28 more Caused by: java.sql.SQLException: java.lang.NullPointerException java.lang.NullPointerException at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source) at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source) at org.hsqldb.jdbc.JDBCPreparedStatement.<init>(Unknown Source) at org.hsqldb.jdbc.JDBCConnection.prepareStatement(Unknown Source) at org.apache.commons.dbcp.DelegatingConnection.prepareStatement(DelegatingConnection.java:281) at org.apache.commons.dbcp.DelegatingConnection.prepareStatement(DelegatingConnection.java:281) at com.ibm.jbatch.container.services.impl.JDBCPersistenceManagerImpl.setSchemaOnConnection(JDBCPersistenceManagerImpl.java:396) at com.ibm.jbatch.container.services.impl.JDBCPersistenceManagerImpl.getConnection(JDBCPersistenceManagerImpl.java:334) at com.ibm.jbatch.container.services.impl.JDBCPersistenceManagerImpl.createJobInstance(JDBCPersistenceManagerImpl.java:1670) ... 33 more


La compilación de esta declaración preparada da como resultado una NullPointerExcepion con hsqldb :

Caused by: org.hsqldb.HsqlException: java.lang.NullPointerException at org.hsqldb.error.Error.error(Unknown Source) at org.hsqldb.result.Result.newErrorResult(Unknown Source) at org.hsqldb.Session.execute(Unknown Source) ... 41 more Caused by: java.lang.NullPointerException at org.hsqldb.ParserCommand.compileSet(Unknown Source) at org.hsqldb.ParserCommand.compilePart(Unknown Source) at org.hsqldb.ParserCommand.compileStatement(Unknown Source) at org.hsqldb.Session.compileStatement(Unknown Source) at org.hsqldb.StatementManager.compile(Unknown Source) ... 42 more

Sin embargo, cuando lo cambia a una declaración sin marcadores de posición, funciona:

ps = connection.prepareStatement("SET SCHEMA "+schema); ps.execute();