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

ODBC Truncation error with large strings (MS Access MEMO field)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.4.0
    • 1.2.2, 1.3.0
    • core-libs
    • beta
    • x86
    • windows_98, windows_2000



      Name: boT120536 Date: 01/04/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)



      This is the same as review #111086. It is certainly not the same as bug
      4309706, which appears to have been fixed for 1.3. So here it is again:

      Access has a datype memo (longchar) which is mapped to Types.LONGVARCHAR. This
      datatype supports strings up to 1.2G (if you believe Microsoft specs).
      Using a Statement.execute, there is no problem setting fields to strings much)
      larger than 255 bytes, but not with PreparedStatement.setString():

      /* Test1910b */
      import java.sql.*;
      import java.io.*;

      public class Test1910b {
      public static void main(String[] args) throws Exception{
          String s = "x"; for (int i=0; i<8; i++) s += s;

          Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
          Connection conn = DriverManager.getConnection("jdbc:odbc:SomeDSN");
          Statement stmt = conn.createStatement();
          stmt.execute("CREATE TABLE someTable (memoField longchar)");
          PreparedStatement pstmt = conn.prepareStatement("INSERT INTO someTable
      (memoField) VALUES (?)");
          pstmt.setString(1, s);
          pstmt.execute();
      }
      }
      /* end */

      Exception in thread "main" java.sql.SQLException: [Microsoft][ODBC Microsoft Acc
      ess Driver]String data, right truncated (null)
              at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6031)
              at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:6188)
              at sun.jdbc.odbc.JdbcOdbc.SQLExecute(JdbcOdbc.java:2533)
              at sun.jdbc.odbc.JdbcOdbcPreparedStatement.execute(JdbcOdbcPreparedState
      ment.java:217)
              at Test1910b.main(Test1910b.java:29)

      I rate this behaviour as a bug, because it is just a definition of a buffer
      passed to ODBC. Other drivers (IDS, Netdirect, Avenir) do not have this problem.


      (Review ID: 114539)
      ======================================================================

            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: