• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Execute PL/SQL in Java -> NullPointerException

 
Ranch Hand
Posts: 271
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:



 
Ranch Hand
Posts: 385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Change



to

 
Ahmed Bin S
Ranch Hand
Posts: 385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 271
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to our databases forum.
 
We can walk to school together. And we can both read this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic