Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4423012

Regression: PreparedStatement.clearParameters() fails if statement has no "?".

XMLWordPrintable

    • beta
    • x86
    • windows_nt



      Name: boT120536 Date: 03/07/2001


      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
      Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)

      Problem:
      --------
      If a PreparedStatement is build without paramters, the clearParameters()
        statement throws a NullPointerException under JDK1.3, it works fine with
      JDK1.2.2.

      The bug was encounted using enhydra (v3.1) DO objects (Data Layer). The enhydra
      framework makes the call to clearParameters() on the second time the query is
      executed.


      Source Code:
      ------------
      import java.sql.*;
      import java.io.*;

      public class JDBCTest
      {
          final static String URL = "jdbc:odbc:SQLServer";
          final static String STMT ="Select * from board";

          public static void main(String[] args) throws Exception
          {

              Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();

              Connection conn = DriverManager.getConnection(URL,"","");
              PreparedStatement stmt = conn.prepareStatement(STMT);

              stmt.clearParameters();

              stmt.close();
              conn.close();
          }
      }


      Error message:
      --------------
      Exception in thread "main" java.lang.NullPointerException
              at sun.jdbc.odbc.JdbcOdbcPreparedStatement.clearParameters
      (JdbcOdbcPreparedStatement.java:1012)
              at JDBCTest.main(JDBCTest.java:22)
      (Review ID: 117304)
      ======================================================================

            jbrucesunw Jonathan Bruce (Inactive)
            bonealsunw Bret O'neal (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: