home clear 64x64
en blue 200x116 de orange 200x116 info letter User
suche 36x36
Neueste VersionenFixList
11.1.0.7 FixList
10.5.0.9 FixList
10.1.0.6 FixList
9.8.0.5 FixList
9.7.0.11 FixList
9.5.0.10 FixList
9.1.0.12 FixList
Haben Sie Probleme? - Kontaktieren Sie uns.
Kostenlos registrieren anmeldung-x26
Kontaktformular kontakt-x26

DB2 - Problembeschreibung

Problem IC62555 Status: Geschlossen

CLASSCASTEXCEPTION WHEN CALLING EXECUTEBATCH() IF A STATEMENT PARAMETER
THAT GETS CAST TO DECIMAL WAS SET USING SETLONG()

Produkt:
DB2 FOR LUW / DB2FORLUW / 970 - DB2
Problembeschreibung:
Using the JCC driver (Java Common Client, also known as 
IBM Data Server Driver for JDBC and SQLJ), 
when you call the executeBatch() method of 
PreparedStatement to execute certain INSERT statements, and 
you have used the setLong() method of PreparedStatement to set 
the value of a statement parameter that is cast to 
DECIMAL, a java.lang.ClassCastException occurs. 
 
The problem occurs only if all the following conditions are 
true: 
- the JCC property deferPrepares=true 
- the database server is DB2 on zOS 
- the INSERT statement is of the form 
   INSERT INTO ... SELECT ... CAST(? AS DECIMAL(...))" 
 
 
 
The problem can be reproduced by creating a table like this: 
 
 create table tab1(col1 decimal(18, 0)); 
 
 
and then running a program like this: 
 
import java.sql.Connection; 
import java.sql.DriverManager; 
import java.sql.PreparedStatement; 
import java.sql.SQLException; 
 
public class TestPrepare 
{ 
    public static void main(String[] args) 
    { 
        Connection cnn = null; 
        PreparedStatement ps = null; 
 
        try 
        { 
 
            Class.forName("com.ibm.db2.jcc.DB2Driver"); 
 
            cnn = DriverManager.getConnection( 
             "<connection string>","<username>","<password>"); 
 
            ps = cnn.prepareStatement( 
             "insert into tab1(col1) select cast(? as 
               decimal(18,0)) from tab1" 
             ); 
            ps.setLong(1, 6); 
 
            ps.addBatch(); 
            ps.executeBatch(); 
        } 
 
        catch (Exception e) 
        { 
            if (e.getMessage() != null) 
            { 
                System.out.println(e.getMessage()); 
            } 
            e.printStackTrace(); 
        } 
        finally 
        { 
           if (ps != null) 
            { 
                try 
                { 
                    ps.close(); 
                } 
                catch (SQLException e) {} 
            } 
            if (cnn != null) 
            { 
                try 
                { 
                    cnn.close(); 
                } 
                catch (SQLException e) {} 
            } 
        } 
    } 
}
Problem-Zusammenfassung:
**************************************************************** 
* USERS AFFECTED:                                              * 
* Users of the IBM Data Server Driver for JDBC and SQLJ (also  * 
* called the JCC driver) who connect to DB2 on zOS             * 
**************************************************************** 
* PROBLEM DESCRIPTION:                                         * 
* See Error Description                                        * 
**************************************************************** 
* RECOMMENDATION:                                              * 
* .                                                            * 
****************************************************************
Local-Fix:
To set the value of the statement parameter, call 
setBigDecimal() or setObject() instead of setLong(). 
 
That means, in the example program, replace the line: 
 ps.setLong(1, 6) 
with: 
 ps.setBigDecimal(1, new java.math.BigDecimal(6)); 
or: 
 ps.setObject(1, "6");
verfügbare FixPacks:
DB2 Version 9.7 Fix Pack 2 for Linux, UNIX, and Windows
DB2 Version 9.7 Fix Pack 3 for Linux, UNIX, and Windows
DB2 Version 9.7 Fix Pack 3a for Linux, UNIX, and Windows
DB2 Version 9.7 Fix Pack 1 for Linux, UNIX, and Windows
DB2 Version 9.7 Fix Pack 4 for Linux, UNIX, and Windows
DB2 Version 9.7 Fix Pack 5 for Linux, UNIX, and Windows
DB2 Version 9.7 Fix Pack 7 for Linux, UNIX, and Windows
DB2 Version 9.7 Fix Pack 9a for Linux, UNIX, and Windows
DB2 Version 9.7 Fix Pack 6 for Linux, UNIX, and Windows
DB2 Version 9.7 Fix Pack 8 for Linux, UNIX, and Windows
DB2 Version 9.7 Fix Pack 9 for Linux, UNIX, and Windows
DB2 Version 9.7 Fix Pack 10 for Linux, UNIX, and Windows

Lösung
Problem was first fixed in Version 9.7 Fix Pack 1
Workaround
As a workaround, to set the value of the statement parameter, 
 
call setBigDecimal() or setObject() instead of setLong(). 
 
That means, in the example program, replace the line: 
 
ps.setLong(1, 6) 
 
with: 
ps.setBigDecimal(1, new java.math.BigDecimal(6)); 
 
or: 
ps.setObject(1, "6");
Weitere Daten
Datum - Problem gemeldet    :
Datum - Problem geschlossen :
Datum - der letzten Änderung:
14.08.2009
02.02.2011
02.02.2011
Problem behoben ab folgender Versionen (IBM BugInfos)
9.7.FP1
Problem behoben lt. FixList in der Version
9.7.0.1 FixList