2016-07-12 12 views
3

HSQLDBとの接続が必要なJbatchサービスを作成していますが、ある時点でNullPointerException(およびいくつかのSQLExceptions/PersistenceExceptions)がスローされます。デバッグ私はクラスJDBCPersistenceManagerImpl.javaでSCHEMAを?に設定しましたが、HSQLDBのようにサポートされていないようです。HSQLDB prepareStatement( "SET SCHEMA?")エラー

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()"); 
    } 

修正方法についてのご意見はありますか?私はすでに別のデータベース(H2データベース)を試してきましたが、問題は同じです。

これは、完全なスタックトレースです:

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 

答えて

0

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

、プレースホルダ、動作:

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

彼はクラスを変更することはできません、JDBCPersistenceManagerImpl.javaにあります –

+0

'javax.batch.operations.JobStartException:com.ibm.jbatch.container.exception.PersistenceException:java.sql.SQLException:java.lang.NullPointerException java.lang .NullPointerException' –

+0

例外の完全なスタックトレースで質問を編集しました –