Results 1 to 9 of 9
  1. #1
    marvelk is offline Member
    Join Date
    Jan 2011
    Posts
    7
    Rep Power
    0

    Default null pointer exception

    this codes gives me a null pointer exception when i try to update the database




    this is the section i added before i started getting the exception
    try {
    // con.setAutoCommit(false);
    ps1 = con.prepareStatement("update member2 set address = ?, where name = ? " );
    // String nam = (String) jComboBox8.getSelectedItem();
    String add = jTextArea2.getText();
    // String sex = (String) jComboBox4.getSelectedItem();
    // String age = (String) jComboBox5.getSelectedItem();
    // String job = jTextField5.getText();
    // String contra = jTextField6.getText();
    String nam = jComboBox8.getSelectedItem().toString();


    ps2.setString(1, add);
    // ps2.setString(2, sex);
    // ps2.setString(3, age);
    // ps2.setString(4, job);
    // ps2.setString(5, contra);
    ps2.setString(6, nam);

    i'll appreciate your assistance

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    8

    Default

    On which line?

    Although I don't know why you showed the creation of ps1 with two arguments and then call sets on ps2 using a 6.

    All I can say is that either con is null (since I have no idea how you created it), or ps2 is null as it should be ps1, but both of those are, of course, guesses, since we can't really do anything with random lines of code like this.

  3. #3
    toadaly is offline Senior Member
    Join Date
    Jan 2009
    Posts
    671
    Rep Power
    6

    Default

    Possible reasons:

    con is null,
    jTextArea2 is null
    'add' is null (getText can return null in some situations)
    jComboBox8 is null
    jComboBox8.getSelectedItem() is null (possible if no items are selected)
    nam is null (possible depending on the type of selected item)
    ps2 is null

  4. #4
    marvelk is offline Member
    Join Date
    Jan 2011
    Posts
    7
    Rep Power
    0

    Default

    yes i see that should be ps2 but aside none of the other components are null is there any other error in the code aside from this i'll try and see

  5. #5
    marvelk is offline Member
    Join Date
    Jan 2011
    Posts
    7
    Rep Power
    0

    Default

    i am actually trying to create a human resource management system and theres a label which should receive the picture of the personell but i dont have any idea how to input or retrieve picture in oracle10i

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    19

    Default

    Show us the stack trace, with the full error message.
    Show us the code (in code tags please).
    Point out the line that the error is thrown from.

    Without any of those we are simply guessing.

  7. #7
    marvelk is offline Member
    Join Date
    Jan 2011
    Posts
    7
    Rep Power
    0

    Default

    this is the edited code
    try {
    con.setAutoCommit(false);
    ps2 = con.prepareStatement("update member2 set address = ?, set sex = ?, set age = ?, set occupation = ?, set monthlycontribution = ? where name = ? " );
    String nam = (String) jComboBox8.getSelectedItem();
    String add = jTextArea2.getText();
    String sex = (String) jComboBox4.getSelectedItem();
    String age = (String) jComboBox5.getSelectedItem();
    String job = jTextField5.getText();
    String contra = jTextField6.getText();




    ps2.setString(1, add);
    ps2.setString(2, sex);
    ps2.setString(3, age);
    ps2.setString(4, job);
    ps2.setString(5, contra);
    ps2.setString(6, nam);




    ps2.executeUpdate();

    JOptionPane.showMessageDialog(null, "your record has been updated");
    } catch (SQLException ex) {
    Logger.getLogger(CPM.class.getName()).log(Level.SE VERE, null, ex);
    }

    and this is the stack trace

    java.sql.SQLException: ORA-01747: invalid user.table.column, table.column, or column specification

    at oracle.jdbc.driver.DatabaseError.throwSqlException (DatabaseError.java:112)
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoe r.java:331)
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoe r.java:288)
    at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java: 743)
    at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4 CPreparedStatement.java:216)
    at oracle.jdbc.driver.T4CPreparedStatement.executeFor Rows(T4CPreparedStatement.java:955)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTi meout(OracleStatement.java:1169)
    at oracle.jdbc.driver.OraclePreparedStatement.execute Internal(OraclePreparedStatement.java:3285)
    at oracle.jdbc.driver.OraclePreparedStatement.execute Update(OraclePreparedStatement.java:3368)
    at myprojectwork.CPM.jButton8ActionPerformed(CPM.java :1043)
    at myprojectwork.CPM.access$500(CPM.java:25)
    at myprojectwork.CPM$6.actionPerformed(CPM.java:443)
    at javax.swing.AbstractButton.fireActionPerformed(Abs tractButton.java:1995)
    at javax.swing.AbstractButton$Handler.actionPerformed (AbstractButton.java:2318)
    at javax.swing.DefaultButtonModel.fireActionPerformed (DefaultButtonModel.java:387)
    at javax.swing.DefaultButtonModel.setPressed(DefaultB uttonModel.java:242)
    at javax.swing.plaf.basic.BasicButtonListener.mouseRe leased(BasicButtonListener.java:236)
    at java.awt.Component.processMouseEvent(Component.jav a:6038)
    at javax.swing.JComponent.processMouseEvent(JComponen t.java:3260)
    at java.awt.Component.processEvent(Component.java:580 3)
    at java.awt.Container.processEvent(Container.java:205 8)
    at java.awt.Component.dispatchEventImpl(Component.jav a:4410)
    at java.awt.Container.dispatchEventImpl(Container.jav a:2116)
    at java.awt.Component.dispatchEvent(Component.java:42 40)
    at java.awt.LightweightDispatcher.retargetMouseEvent( Container.java:4322)
    at java.awt.LightweightDispatcher.processMouseEvent(C ontainer.java:3986)
    at java.awt.LightweightDispatcher.dispatchEvent(Conta iner.java:3916)
    at java.awt.Container.dispatchEventImpl(Container.jav a:2102)
    at java.awt.Window.dispatchEventImpl(Window.java:2429 )
    at java.awt.Component.dispatchEvent(Component.java:42 40)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java: 599)
    at java.awt.EventDispatchThread.pumpOneEventForFilter s(EventDispatchThread.java:273)
    at java.awt.EventDispatchThread.pumpEventsForFilter(E ventDispatchThread.java:183)
    at java.awt.EventDispatchThread.pumpEventsForHierarch y(EventDispatchThread.java:173)
    at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:168)
    at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:160)
    at java.awt.EventDispatchThread.run(EventDispatchThre ad.java:121)

  8. #8
    marvelk is offline Member
    Join Date
    Jan 2011
    Posts
    7
    Rep Power
    0

    Default

    the full stack trace here
    java.sql.SQLException: ORA-01747: invalid user.table.column, table.column, or column specification

    at oracle.jdbc.driver.DatabaseError.throwSqlException (DatabaseError.java:112)
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoe r.java:331)
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoe r.java:288)
    at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java: 743)
    at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4 CPreparedStatement.java:216)
    at oracle.jdbc.driver.T4CPreparedStatement.executeFor Rows(T4CPreparedStatement.java:955)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTi meout(OracleStatement.java:1169)
    at oracle.jdbc.driver.OraclePreparedStatement.execute Internal(OraclePreparedStatement.java:3285)
    at oracle.jdbc.driver.OraclePreparedStatement.execute Update(OraclePreparedStatement.java:3368)
    at myprojectwork.CPM.jButton8ActionPerformed(CPM.java :1043)
    at myprojectwork.CPM.access$500(CPM.java:25)
    at myprojectwork.CPM$6.actionPerformed(CPM.java:443)
    at javax.swing.AbstractButton.fireActionPerformed(Abs tractButton.java:1995)
    at javax.swing.AbstractButton$Handler.actionPerformed (AbstractButton.java:2318)
    at javax.swing.DefaultButtonModel.fireActionPerformed (DefaultButtonModel.java:387)
    at javax.swing.DefaultButtonModel.setPressed(DefaultB uttonModel.java:242)
    at javax.swing.plaf.basic.BasicButtonListener.mouseRe leased(BasicButtonListener.java:236)
    at java.awt.Component.processMouseEvent(Component.jav a:6038)
    at javax.swing.JComponent.processMouseEvent(JComponen t.java:3260)
    at java.awt.Component.processEvent(Component.java:580 3)
    at java.awt.Container.processEvent(Container.java:205 8)
    at java.awt.Component.dispatchEventImpl(Component.jav a:4410)
    at java.awt.Container.dispatchEventImpl(Container.jav a:2116)
    at java.awt.Component.dispatchEvent(Component.java:42 40)
    at java.awt.LightweightDispatcher.retargetMouseEvent( Container.java:4322)
    at java.awt.LightweightDispatcher.processMouseEvent(C ontainer.java:3986)
    at java.awt.LightweightDispatcher.dispatchEvent(Conta iner.java:3916)
    at java.awt.Container.dispatchEventImpl(Container.jav a:2102)
    at java.awt.Window.dispatchEventImpl(Window.java:2429 )
    at java.awt.Component.dispatchEvent(Component.java:42 40)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java: 599)
    at java.awt.EventDispatchThread.pumpOneEventForFilter s(EventDispatchThread.java:273)
    at java.awt.EventDispatchThread.pumpEventsForFilter(E ventDispatchThread.java:183)
    at java.awt.EventDispatchThread.pumpEventsForHierarch y(EventDispatchThread.java:173)
    at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:168)
    at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:160)
    at java.awt.EventDispatchThread.run(EventDispatchThre ad.java:121)
    java.sql.SQLException: ORA-01747: invalid user.table.column, table.column, or column specification

    at oracle.jdbc.driver.DatabaseError.throwSqlException (DatabaseError.java:112)
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoe r.java:331)
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoe r.java:288)
    at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java: 743)
    at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4 CPreparedStatement.java:216)
    at oracle.jdbc.driver.T4CPreparedStatement.executeFor Rows(T4CPreparedStatement.java:955)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTi meout(OracleStatement.java:1169)
    at oracle.jdbc.driver.OraclePreparedStatement.execute Internal(OraclePreparedStatement.java:3285)
    at oracle.jdbc.driver.OraclePreparedStatement.execute Update(OraclePreparedStatement.java:3368)
    at myprojectwork.CPM.jButton8ActionPerformed(CPM.java :1043)
    at myprojectwork.CPM.access$500(CPM.java:25)
    at myprojectwork.CPM$6.actionPerformed(CPM.java:443)
    at javax.swing.AbstractButton.fireActionPerformed(Abs tractButton.java:1995)
    at javax.swing.AbstractButton$Handler.actionPerformed (AbstractButton.java:2318)
    at javax.swing.DefaultButtonModel.fireActionPerformed (DefaultButtonModel.java:387)
    at javax.swing.DefaultButtonModel.setPressed(DefaultB uttonModel.java:242)
    at javax.swing.plaf.basic.BasicButtonListener.mouseRe leased(BasicButtonListener.java:236)
    at java.awt.Component.processMouseEvent(Component.jav a:6038)
    at javax.swing.JComponent.processMouseEvent(JComponen t.java:3260)
    at java.awt.Component.processEvent(Component.java:580 3)
    at java.awt.Container.processEvent(Container.java:205 8)
    at java.awt.Component.dispatchEventImpl(Component.jav a:4410)
    at java.awt.Container.dispatchEventImpl(Container.jav a:2116)
    at java.awt.Component.dispatchEvent(Component.java:42 40)
    at java.awt.LightweightDispatcher.retargetMouseEvent( Container.java:4322)
    at java.awt.LightweightDispatcher.processMouseEvent(C ontainer.java:3986)
    at java.awt.LightweightDispatcher.dispatchEvent(Conta iner.java:3916)
    at java.awt.Container.dispatchEventImpl(Container.jav a:2102)
    at java.awt.Window.dispatchEventImpl(Window.java:2429 )
    at java.awt.Component.dispatchEvent(Component.java:42 40)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java: 599)
    at java.awt.EventDispatchThread.pumpOneEventForFilter s(EventDispatchThread.java:273)
    at java.awt.EventDispatchThread.pumpEventsForFilter(E ventDispatchThread.java:183)
    at java.awt.EventDispatchThread.pumpEventsForHierarch y(EventDispatchThread.java:173)
    at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:168)
    at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:160)
    at java.awt.EventDispatchThread.run(EventDispatchThre ad.java:121)

  9. #9
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    8

    Default

    One of the column names doesn't exist or is a "reserved" word meaning it needs to be surrounded by quotes, and "name" looks like a good candidate for that.

    i.e. instead of
    Java Code:
    "update member2 set address = ?, set sex = ?, set age = ?, set occupation = ?, set monthlycontribution = ? where name = ? "
    so
    Java Code:
    "update member2 set address = ?, set sex = ?, set age = ?, set occupation = ?, set monthlycontribution = ? where \"name\" = ? "

Similar Threads

  1. Null pointer exception
    By izzy in forum New To Java
    Replies: 5
    Last Post: 03-22-2010, 05:19 PM
  2. Null Pointer exception
    By diegoyj in forum New To Java
    Replies: 7
    Last Post: 01-29-2010, 04:17 PM
  3. Null pointer exception?
    By coffee in forum New To Java
    Replies: 4
    Last Post: 08-03-2009, 03:22 AM
  4. Null Pointer Exception
    By andre1011 in forum Advanced Java
    Replies: 4
    Last Post: 02-07-2009, 03:30 AM
  5. Null Pointer Exception
    By ScKaSx in forum New To Java
    Replies: 1
    Last Post: 01-24-2009, 11:27 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •