double array storage problem

Don Smyth
  • Don Smyth

    Don Smyth - 2013-07-27

    I would like to store 10,000 double items in a double array in a table.
    However if I try to store any more than 1024 double items I get the following error: data exception: array data, right truncation.
    Example code:

    //if numberRows is 1024 or less then all works OK
    int numberRows = 10000;
    for (int i = 0; i < numberRows; i++) {
        testData_ = (double) (i);

    Double dataObjectArray = toObject(testData);
    Connection connect = getConnection();
    java.sql.Array javaSqlArrayData = connect.createArrayOf("DOUBLE", dataObjectArray);
    String sqlStatement = (new StringBuilder())
    .append("INSERT INTO TestTable  (id, data)VALUES (").append(ID).append(", ")

    Is there a setting somewhere that I need to change to allow storage of size > 2^10 items?_

  • Fred Toussi

    Fred Toussi - 2013-07-27

    Each ARRAY column has a maximum size. If you do not specify this, the default max size is used. Declare the array with the required maximum size:


  • Don Smyth

    Don Smyth - 2013-07-28

    Thank Fred,

    I tested the speed of a prepared satements for a 10,000 item Double Array with javaSqlArrayData as per above versus an Object column with a 10,000 item Double Array inserted as an object. Using an object is much quicker and has the advantage that the size is not locked in.



  • Fred Toussi

    Fred Toussi - 2013-07-28

    You use an SQL ARRAY when you want to access the individual elements in your SQL statements.


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks