0

I have the below code

oracle.jdbc.driver.OracleConnection connection = (oracle.jdbc.driver.OracleConnection)

oracle.apps.jtf.aom.transactions.TransactionScope.getNewConnection()

the code is not throwing any exception here but

when I do

p = connection.p(stringbuffer.toString())

am getting Null pointer exception.

could you please help me why ?

is the connection in the first line actually established ?

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
F0cus
  • 585
  • 3
  • 18
  • 52
  • 1
    either `connection` or `stringbuffer` is null - probably the stringbuffer, since the connection works, as you said. – Japu_D_Cret Mar 25 '17 at 17:56
  • possible duplicate of http://stackoverflow.com/questions/218384/what-is-a-nullpointerexception-and-how-do-i-fix-it – Japu_D_Cret Mar 25 '17 at 17:57
  • Hi Japu, String buffer is not null its a query and I printed. its a valid query. – F0cus Mar 25 '17 at 17:59
  • please help me how to confirm the connection is null. any method like connection. help me to verify that – F0cus Mar 25 '17 at 18:00
  • 1
    The stack trace tells you the line that has the NPE. One of the references on that line is null; make it not so. Stop insisting that your code is correct; the JVM runtime knows better. Believe it. – duffymo Mar 25 '17 at 18:01
  • apologize .. actually I am about to say I did log messages like out.println(stringbuffer.toString()) prints the sql query in the page. so I think the connection may have the issue. but I am not sure why the connection in the first line did not throw any exception? and what there in 'connection' – F0cus Mar 25 '17 at 18:06
  • @mysticLife debug through your code and check what exactly has a null value and why. if your IDE(if you use any) does not support debugging, try printing after every step – Japu_D_Cret Mar 25 '17 at 18:09
  • Why do you think it should throw an exception? Why are you using Oracle classes? Better to stick to the JDBC interfaces and keep your code portable. Start with the basics. You sound like you are doing this for the first time. https://docs.oracle.com/javase/tutorial/jdbc/ – duffymo Mar 25 '17 at 18:11
  • @Japu_D_Cret . Yes Japu .. I don't have an IDE. so can I print like out.println(connection) ? I suspected this may not work .. but I will try this – F0cus Mar 25 '17 at 18:12
  • @duffymo - yes I am doing this for the first time.. am a PL/SQL developer .. accidently have to do some java code migration from EBS 11i to R12 . but this part is giving me trouble. – F0cus Mar 25 '17 at 18:14
  • its a re-implementation project 11i to R12 - all these codes are old . atleast 10 years old. – F0cus Mar 25 '17 at 18:15
  • 1
    Should not be using Oracle classes. Start with the JDBC tutorial I gave you. Do you know Java at all? PL/SQL does not qualify you as a Java developer. If you stick to JDBC interfaces this would be a simple JAR upgrade. – duffymo Mar 25 '17 at 18:15

0 Answers0