Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2005

    Post Unanswered: NullPointerException with executeUpdate

    Hi there. I'm using server-side JDBC with Oracle to implement some business logic in my tables. I'm running into a hard-to-pin-down NullPointerException that only occurs in certain circumstances. I'm concerned it may have to do with concurrency issues, or perhaps threading, so I've made the method below synchronized, although that didn't seem to help. Here is my code (a bit lengthy):

    synchronized protected int setValueQuery(int id, String sql, Object valueObj) {

    int updateCount = 0;
    PreparedStatement ps = null;
    ResultSet rs = null;

    logger.debug("id: " + id);
    logger.debug("sql: " + sql);
    logger.debug("value: " + valueObj);

    if (valueObj == null ||
    ( valueObj instanceof String &&
    ((String)valueObj).equals("") ) ) {
    // We shouldn't get here.
    logger.error("Value to set is null!");
    return 0;

    if (sql== null) {
    // We shouldn't get here.
    logger.error("SQL is null!");
    return 0;

    try {
    // Update a row in the table.
    if (m_conn == null || m_conn.isClosed()) {
    logger.error(this"No connection!");
    return 0;
    if (ps == null) {
    logger.error("Null statement!");
    return 0;

    // Find out what sort of value Object we have.
    // Right now, we're handling NUMERIC and VARCHAR if (valueObj instanceof String) {
    logger.debug("String valueObj: " + valueObj);
    } else if (valueObj instanceof Integer) {
    logger.debug("Integer valueObj.");

    } else {
    // We don't handle this type.
    logger.warn("Unhandled Object type: " +
    return 0;


    logger.debug("Executing update...");
    updateCount = ps.executeUpdate();
    } catch (SQLException ex) {
    logger.fatal("SQLException : " + ex);
    return 0;
    } finally {
    logger.debug("Calling close...");

    return 1;

    The closeStatement routine closes and sets to null both the ResultSet and the PreparedStatement. I'm checking for nulls everywhere I can think of, here, and yet here is the output:

    id: 151
    sql: UPDATE ims.pr_address SET modified_by = USER, modifytimestamp = LOCALTIMESTAMP,postal_cd = ? WHERE dukeid = ? AND source_cd = 'idms' AND type_cd = 'mail' AND locale = 'work' AND seq = 0
    value: 27708
    String valueObj: 27708
    Executing update...
    SQLException (duWorkMailAddressZip.setValueQuery): oracle.jdbc.driver.OracleSQLException: ORA-29532: Java call terminated by uncaught Java exception: java.lang.NullPointerException
    ORA-06512: at "IMS.PR_XFORM", line 0
    ORA-06512: at "IMS.PR_ADDRESS_PKG", line 87
    ORA-06512: at "IMS.ADIU_PR_ADDRESS", line 3
    ORA-04088: error during execution of trigger 'IMS.ADIU_PR_ADDRESS'
    Calling close...

    Again, this is not consistent - there are times when they exact same data passed in works fine. It appears to be when a lot of traffic is happening at once on the table, which is why I'm concerned about concurrency. Can anyone give me a clue? Any help is most appreciated.

  2. #2
    Join Date
    Jan 2005


    It turns out that the NullPointerException was originating from another piece of code way down the line of stored procedures being called from various triggers fired when this update occurred. So there was no problem with this piece of code. Note for those with NullPointerExceptions in similar circumstances: make sure you understand the entire cycle of procedures being called, because it will appear to be a problem with the original update.

Posting Permissions

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