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

DataTruncation object retrun null SQLState when read is set to true/false.

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b59
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Verified

      Description

      JDK : 6.0 -b47 with jdbc4.jar
      Platform[s] : Sol 10 Sparc
      switch/Mode : default
      DB : ORCL
      Failing Test :
      exceptions/data_trucation/dataTrun001_001 compile_and_execute
      exceptions/data_trucation/dataTrun001_002 compile_and_execute

      Description:
      ===========
      The SQLState retrun as null when read is set to true/false.


      javadoc:
      Creates a DataTruncation object with the SQLState initialized to 01004 when read is set to true and 22001 when read is set to false

      How to reproduce:
      ====================
      javac myexpection.java
      java myexpection

      Test output:
      =============
      DataTruncation caught.
      Expected getCause is : null
      Expected reason is : Data truncation
      Expected sqlState is : 01004
      Expected index is : 99
      Expected data size is : 200
      Expected transfer size is : 123
      Expected parameter is : true
      Expected vendor code is : 0
      read is set to : true
      =====================================
      Return getCause is : null
      Return reason is : Data truncation
      Return sqlState is : null
      Return index is : 99
      Return data size is : 200
      Return transfer size is : 123
      Expected parameter is : true
      Return vendor code is : 0
      Stack trace:
      java.sql.DataTruncation: Data truncation
              at myexpection.main(myexpection.java:21)
      Exception in thread "main" java.lang.NullPointerException
              at myexpection.main(myexpection.java:48)


      Specific Machine Info:
      =====================
      SunOS orthello 5.10 Generic sun4u sparc SUNW,Ultra-60

      myexpection.java
      =================
      import java.lang.Exception.*;
      import java.sql.*;
      import java.util.*;
      import java.io.*;

      public class myexpection {
          public static void main (String args[]) {
              boolean Status = false;
             
              boolean myRead = true;
              boolean myParameter = true;
              String reasons = "Data truncation";
              String sqlState = "01004";
              int myVendorCode = 0;
              int myIndex = 99;
              int myDataSize = 200;
              int myTransferSize = 123;
              
              try {
                   throw new DataTruncation(myIndex,myParameter,myRead,myDataSize,myTransferSize);
              }catch (DataTruncation tEx){
                  System.out.println("DataTruncation caught.");
                  
                  System.out.println("Expected getCause is : null");
                  System.out.println("Expected reason is : " + reasons);
                  System.out.println("Expected sqlState is : " + sqlState);
                  System.out.println("Expected index is : " + myIndex);
                  System.out.println("Expected data size is : " + myDataSize);
                  System.out.println("Expected transfer size is : " + myTransferSize);
                  System.out.println("Expected parameter is : " + myParameter);
                  System.out.println("Expected vendor code is : " + myVendorCode);
                  System.out.println("read is set to : " + myRead);
                  
                  System.out.println("=====================================");
                  System.out.println("Return getCause is : " + tEx.getCause());
                  System.out.println("Return reason is : " + tEx.getMessage());
                  System.out.println("Return sqlState is : " + tEx.getSQLState());
                  System.out.println("Return index is : " + tEx.getIndex());
                  System.out.println("Return data size is : " + tEx.getDataSize());
                  System.out.println("Return transfer size is : " + tEx.getTransferSize());
                  System.out.println("Expected parameter is : " + tEx.getParameter());
                  System.out.println("Return vendor code is : " + tEx.getErrorCode());
                  
                  System.err.println("Stack trace:");
                  tEx.printStackTrace();
                            
                  if (tEx.getCause() == null &&
                          tEx.getMessage().toString().equals(reasons) &&
                          tEx.getSQLState().toString().equals(sqlState) &&
                          tEx.getErrorCode() == myVendorCode &&
                          tEx.getIndex() == myIndex &&
                          tEx.getDataSize() == myDataSize &&
                          tEx.getTransferSize() == myTransferSize &&
                          tEx.getParameter() == myParameter ) {
                      Status = true;
                  }
              }
              System.out.println("Status = " +Status);
              
          }
          
      }

        Attachments

          Activity

            People

            Assignee:
            skaushiksunw Shreyas Kaushik (Inactive)
            Reporter:
            tacheung Tak Wing Cheung (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: