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

Can't get PreparedStatement.setDate to use a java.sql.Date object

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P5 P5
    • 1.3.0
    • 1.1.2
    • core-libs
    • None
    • kestrel
    • x86
    • windows_95



      Name: joT67522 Date: 08/22/97


      I'm using Java's JDBC to attempt to execute the relational database query
      embedded in
      the prepared statement below. The code compiles fine, but when I execute it, an
      SQLException
      is generated when the program attempts to bind the second parameter using the
      "setDate()"
      function. The exception message reads "java.sql.SQLException: Restricted data
      type attribute violation"

      The data source is a Microsoft Access database connected through and ODBC
      driver. I'm also
      using the XDB JetConnect JDBC driver. (Note that I was able to get the same
      query to work with
      the same database using XDB's JetConnect API that mimics ODBC calls.)

      Appreciate any help I can get, or especially, any examples of someone using the
      PreparedStatement.setDate() function.
      --Mike
      -----------------------------------------------------------------------------
      PreparedStatement sourcePStmt = con.prepareStatement
      ("select ssn, first_name, last_name " +
         "from stumast " +
      "where curric_id = ? " +
      "and curric_enroll_date " +
      "between ? AND ?");

      sourcePStmt.setString(1, "00037");
      sourcePStmt.setDate(2, new java.sql.Date(1997,01,31));
      sourcePStmt.setDate(3, new java.sql.Date(1997,07,01);




      company - Air Force Institute of Technology , email - ###@###.###
      ======================================================================

            swhitesunw Seth White (Inactive)
            johsunw Joon Oh (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: