3

I have a sql script for oracle database:

set define off;
   CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "XYZ" AS
   import javax.crypto.SecretKey;
.......
   import java.security.NoSuchProviderException;
public class XYZ {
   .... fields
   .... methods
}
/

I'm trying to execute this statement using following java code:

String createStoredProcedureSqlString = new String(Files.readAllBytes(storedProcedureSqlFile.toPath()));
try (Connection connection = dataSource.getConnection();
     Statement statement = connection.createStatement()) {
    statement.execute(createStoredProcedureSqlString);
    }

After executing this code I faced with exception message:

java.sql.SQLException: Non supported SQL92 token at position: 479

I believe that this exception occurs while script contains "{" or "}" symbols. But I don't really know how to escape them and not affect script itself.

What am I doing wrong?

6
  • Did you take a look at stackoverflow.com/questions/12244591/…? Commented Dec 19, 2017 at 17:09
  • Yes, I did. This topic is all about replacing { symbol. This solution doesn't suit me Commented Dec 19, 2017 at 17:17
  • I believe this would be your answer. stackoverflow.com/a/12281574/3179169. You cannot use { } and the comments say that you can use some other characters and then replace it. Commented Dec 19, 2017 at 17:19
  • 3
    Why the need to run through JDBC? Just use sqlplus. Commented Dec 19, 2017 at 17:28
  • 3
    I doubt JDBC is going to understand SQL*Plus commands like set define off; Surely it expects a single SQL statement. Commented Dec 19, 2017 at 19:07

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.