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

setCharacterStream() on MS Access Memo field causes "Invalid precision value"

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.4.0
    • 1.4.0
    • core-libs
    • beta3
    • x86
    • windows_2000



      Name: rmT116609 Date: 08/21/2001


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

      I try to insert values into MS Access table field with type Memo using method
      setCharacterStream().

      import java.sql.*;
      import java.io.*;

      public class TestMemo
      {
           public static void main (String[] args) throws Exception {
                     Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                     Connection con = DriverManager.getConnection("jdbc:odbc:LEGO");
                     Statement stmt = con.createStatement();
                     try {
                          stmt.execute("DROP TABLE test_table"); //drop table if exist
                     } catch (Exception e) {/*do nothing*/}
                     stmt.execute("CREATE TABLE test_table (test_field longchar)"); //create table with one field (type MEMO)

                     PreparedStatement ps = con.prepareStatement("INSERT INTO test_table (test_field) VALUES (?)");
                     String s = "";
                     for(int i=0; i<555; i++){s = s + "a";} //creates long string

                     Reader r = new StringReader(s);
                     ps.setCharacterStream(1, r, s.length());
                     ps.execute();
                }
      }

      ------------------------------------------------------------------------------
      The output is
      Exception in thread "main" java.sql.SQLException: [Microsoft][ODBC
      Microsoft Access Driver]Invalid precision value
              at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
              at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
              at sun.jdbc.odbc.JdbcOdbc.SQLBindInParameterAtExec(Unknown Source)
              at sun.jdbc.odbc.JdbcOdbcPreparedStatement.setStream(Unknown Source)
              at sun.jdbc.odbc.JdbcOdbcPreparedStatement.setCharacterStream(Unknown Source)
              at TestMemo.main(TestMemo.java:21)

      The same problem occurs with JDK1.4.0-beta

      Acctually Bug ID: 4401822 does not cover the problems with setCharacterStream, but with setString method.
      (Review ID: 130121)
      ======================================================================

            jbrucesunw Jonathan Bruce (Inactive)
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: