Forum Stats

  • 3,734,697 Users
  • 2,247,027 Discussions
  • 7,857,458 Comments

Discussions

Problem using @@ in script from java

Andrii Huryn
Andrii Huryn Member Posts: 6
edited Feb 16, 2020 11:51AM in SQLcl

Hi everybody, I've found example how to use sqlcl with Java (https://github.com/oracle/oracle-db-tools/tree/master/sqlcl/java)

And tried to use it in my code (https://github.com/SimplyAMan/use-sqlcl-java-example), but one of my test fails. I'm talking about testRunManyFromOne from src\test\java\ua\huryn\sqlcl\RunSQLScriptTest.java

Error:

java.lang.NullPointerException

at oracle.dbtools.raptor.newscriptrunner.SQL.executeQuery(SQL.java:701)

at oracle.dbtools.raptor.newscriptrunner.SQL.run(SQL.java:83)

at oracle.dbtools.raptor.newscriptrunner.ScriptRunner.runSQL(ScriptRunner.java:405)

at oracle.dbtools.raptor.newscriptrunner.ScriptRunner.run(ScriptRunner.java:231)

at oracle.dbtools.raptor.newscriptrunner.ScriptExecutor.run(ScriptExecutor.java:344)

at oracle.dbtools.raptor.newscriptrunner.ScriptExecutor.run(ScriptExecutor.java:227)

at oracle.dbtools.raptor.newscriptrunner.SQLPLUS.runExecuteFile(SQLPLUS.java:3900)

at oracle.dbtools.raptor.newscriptrunner.SQLPLUS.run(SQLPLUS.java:209)

at oracle.dbtools.raptor.newscriptrunner.ScriptRunner.runSQLPLUS(ScriptRunner.java:421)

at oracle.dbtools.raptor.newscriptrunner.ScriptRunner.run(ScriptRunner.java:258)

at oracle.dbtools.raptor.newscriptrunner.ScriptExecutor.run(ScriptExecutor.java:344)

at oracle.dbtools.raptor.newscriptrunner.ScriptExecutor.run(ScriptExecutor.java:227)

at oracle.dbtools.raptor.newscriptrunner.SQLPLUS.runExecuteFile(SQLPLUS.java:3900)

at oracle.dbtools.raptor.newscriptrunner.SQLPLUS.run(SQLPLUS.java:209)

at oracle.dbtools.raptor.newscriptrunner.ScriptRunner.runSQLPLUS(ScriptRunner.java:421)

at oracle.dbtools.raptor.newscriptrunner.ScriptRunner.run(ScriptRunner.java:258)

at oracle.dbtools.raptor.newscriptrunner.ScriptExecutor.run(ScriptExecutor.java:344)

at oracle.dbtools.raptor.newscriptrunner.ScriptExecutor.run(ScriptExecutor.java:227)

at ua.huryn.sqlcl.RunSQLScript.runScript(RunSQLScript.java:93)

at ua.huryn.sqlcl.RunSQLScriptTest.testRunManyFromOne(RunSQLScriptTest.java:74)

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.base/java.lang.reflect.Method.invoke(Method.java:566)

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.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)

at org.junit.runners.ParentRunner.run(ParentRunner.java:363)

at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:106)

at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58)

at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38)

at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:66)

at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.base/java.lang.reflect.Method.invoke(Method.java:566)

at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)

at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)

at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)

at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)

at com.sun.proxy.$Proxy2.processTestClass(Unknown Source)

at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:117)

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.base/java.lang.reflect.Method.invoke(Method.java:566)

at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)

at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)

at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:155)

at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:137)

at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:404)

at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)

at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)

at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)

at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)

at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)

at java.base/java.lang.Thread.run(Thread.java:834)

I can't find solution by myself. Would you mind looking on that? What's wrong with it.

sql system/[email protected]:1818/XE @test\resources\sql\run-many-from-one\run.sql work fine.

To try this you should change username and password :-)

Answers

  • Gaz in Oz
    Gaz in Oz Member Posts: 3,776 Bronze Crown
    edited Feb 16, 2020 2:48AM

    You post 2 web URL's to a git repository and a java error stack with the nullpointerexception error along with title of " " and at the end a call to some script that calls another script and you don't show what either contains... Vague.

    As a general rule of debugging, keep your code simple, build up the complexity in iterations and stop when you hit an error and analyze, fix and continue.

    Which leads to the question, "Does sqlcl work without all the calls to scripts with embedded calls to other scripts?"

    Please post more details like:

    . sqlcl version

    . java version

    . Oracle database version

    . OS you are running it on

    . a short SIMPLE reproducible, runnable example of what you are doing to get the above

    . anything else that would help others to actually help you, like the query that produced above error if not included in point 5

    @ call, again, only if it is not included in your posting in point 5

    As a test, try using a single @ with the full path to the SQL file you are trying to run calling the embedded script call...

    .

  • Andrii Huryn
    Andrii Huryn Member Posts: 6
    edited Feb 16, 2020 11:51AM

    Maybe the question is ambiguous. I've tried my best.

    The first git repository is oracle github repository which shows us how to use sqlcl features from java code.

    And the second one is my own where I dublicate one java class from oracle repository and added my own tests.

    One of this tests use src\test\resources\sql\run-many-from-one\run.sql and fails.

    >sqlcl version

    Release 19.2.1.0 Production

    >java version

    java 11.0.1 2018-10-16 LTS

    >Oracle database version

    Oracle Database 18c Express Edition

    I tried 11.0.2, 12c, 19c too :-)

    >OS you are running it on

    Windows 10

    >a short SIMPLE reproducible

    it's the testRunManyFromOne from src\test\java\ua\huryn\sqlcl\RunSQLScriptTest.java from https://github.com/SimplyAMan/use-sqlcl-java-example

    It's very simple as for me.

    >The script you are calling

    I'm using test\resources\sql\run-many-from-one\run.sql from my repository.

    >As a test, try using a single @ with the full path to the SQL file

    I tried to change the script test\resources\sql\run-many-from-one\run.sql to:

    @c:\Temp\test\01_get_version.sql

    @c:\Temp\test\02_get_instance.sql

    It still fails with the same error.

    But if I run the same script using sqlcl or sqlplus, like:

    sql system/[email protected]:1818/XE @run.sql

    everything works fine.

    So I think that there are some errors in java code that I copied from oracle repository.

Sign In or Register to comment.