• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Execute PL/SQL in Java -> NullPointerException

 
AhFai Chan
Ranch Hand
Posts: 81
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.
I tried executing some PL/SQL in Java and got a NullPointerException. Can anyone see where I went wrong (again ):
Here is the code:



 
Ahmed Bin S
Ranch Hand
Posts: 378
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Change



to

 
Ahmed Bin S
Ranch Hand
Posts: 378
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Two more points:

1) That isn't PL/SQL that you executed - that is plain ANSI SQL.
2) The convention is to start variable names with a lowercase, so you might want to change OraConnection to oraConnection.
 
Ahmed Bin S
Ranch Hand
Posts: 378
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Final point:

The design of your program is wrong. You do not need to do any of that OraConnection=null and then checking that OraConnection isn't null business - if there is a problem setting OraConnection in your program, then the exception handling should take care of it. If there was no exception thrown, then you can assume that it is fine and proceed.
 
AhFai Chan
Ranch Hand
Posts: 81
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ahmed Bin S wrote:Two more points:

1) That isn't PL/SQL that you executed - that is plain ANSI SQL.
2) The convention is to start variable names with a lowercase, so you might want to change OraConnection to oraConnection.


Thanks, that worked well, I am falling for every thing in the book, trying to come back up to speed.

And yes, that's indeed plain ANSI SQL, but I do have reams of old PL/SQL and TSQL though

I don't think that's going to work on SQL Server though, I don't think the ojdbs understands Class.forname(), this is what I have to do next.

 
Campbell Ritchie
Sheriff
Posts: 51332
86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to our databases forum.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic