Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

NullPointerException from stored procedure call - Re-edited

756989Apr 28 2010 — edited May 3 2010
Hi All,

I'm Re-editing this as my first attempt was pretty weak.

I'm attempting to create a Java application that communicates with a Oracle XE edition database using:

Class.forName("oracle.jdbc.driver.OracleDriver");
JOptionPane.showMessageDialog(null, "Driver Loaded");
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@//localhost:1521/xe", "SYSTEM", "root");
JOptionPane.showMessageDialog(null, "Database connected");

This all works fine and I can perform queries and transactional statements from within the java instance.

However, I cannot call stored procedures as i receive a null pointer exception. The stored procedure I am trying to call returns no values however I know it works as I can execute it within SQL Developer. The code below is the java statement that calls the stored procedure, alll the sources I have looked at say this is correct, I have also tried, cs.executeUpdate and Resultset rs when attempting to call the statement.

public void thread_actionsperformed(ActionEvent c)//generates threads
{
try
{
CallableStatement cs = con.prepareCall("{call PROCEDURE2}"); //Calls stored procedure that would generate threaded emails
cs.execute();
JOptionPane.showMessageDialog(null,"Threading algorithm Executed successfully");
}
catch(SQLException ex)
{
ex.printStackTrace();
JOptionPane.showMessageDialog(null,"Threading algorithm Executed unsuccessfully");//Error response
}
catch(NullPointerException ex)
{
ex.printStackTrace();
JOptionPane.showMessageDialog(null,"Threading algorithm Executed unsuccessfully");//Error response
}
}

Could it be that the Java application cannot 'see' the sp? Or is it something to do with the privileges? I've been stumped by this for quite a while now, any help would be greatly appreciated.

java.lang.NullPointerException
at ETA_Final.thread_actionPerformed(ETA_Final.java:332)
at ETA_Final$5.actionPerformed(ETA_Final.java:141)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.AbstractButton.doClick(AbstractButton.java:357)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1223)
at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:1264)
at java.awt.Component.processMouseEvent(Component.java:6263)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3255)
at java.awt.Component.processEvent(Component.java:6028)
at java.awt.Container.processEvent(Container.java:2041)
at java.awt.Component.dispatchEventImpl(Component.java:4630)
at java.awt.Container.dispatchEventImpl(Container.java:2099)
at java.awt.Component.dispatchEvent(Component.java:4460)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4574)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
at java.awt.Container.dispatchEventImpl(Container.java:2085)
at java.awt.Window.dispatchEventImpl(Window.java:2475)
at java.awt.Component.dispatchEvent(Component.java:4460)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

Thanks and regards,

K

Edited by: Outbound86 on 28-Apr-2010 13:58
This post has been answered by 691310 on May 3 2010
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 31 2010
Added on Apr 28 2010
9 comments
3,900 views