PreparedStatement

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • info@daten-host.de

    PreparedStatement

    Hallo zusammnen,
    ich möchte einen VARBINARY-Wert aus einer Tabelle auslesen, diesen in

    einer Datei speichern und später wieder in eine Tabelle einfügen.

    Den Wert hole ich mit einem Select und getString().
    Das Ergebnis (z.B. 011b0148107f007 310850069006e01 671020205400550 149)
    füge ich (nachdem ich es in einer Date gespeichert und später wieder
    ausgelesen habe) mit einem Insert-Statement und PreparedStateme nt
    folgendermaßen ein:


    String value = new String();
    value = "011b0148107f00 7310850069006e0 167102020540055 0149";
    byte[] varByte = value.getBytes( );
    pstmt.setBytes( j, varByte);


    Hier erhalte ich folgenden Fehler:
    com.ibm.db2.jcc .a.SqlException : DB2 SQL error: SQLCODE: -954, SQLSTATE:

    57011, SQLERRMC: null


    Was mache ich falsch?


    Wechen Unterschied gibt es beim setXXX für BINARY, VARBINARY,
    LONGVARBINARY?


    Danke & Grüße...
    Stefan

  • info@daten-host.de

    #2
    Re: PreparedStateme nt

    sorry, I should write in english:

    I like to read VARBINARY-field from a table , save this ín a file and
    write it then into another table.
    I read the field with a select-statement and getString().
    The Result (like: 011b0148107f007 310850069006e01 671020205400550 149) i
    will insert with PreparedStateme nt:

    String value = new String();
    value = "011b0148107f00 7310850069006e0 167102020540055 0149";
    byte[] varByte = value.getBytes( );
    pstmt.setBytes( j, varByte);

    At that point i will get this error:
    Hier erhalte ich folgenden Fehler:
    com.ibm.db2.jcc .a.SqlException : DB2 SQL error: SQLCODE: -954, SQLSTATE:

    57011, SQLERRMC: null

    What is wrong?
    What is the difference in the setXXX-Statement with BINARY, VARBINARY,
    LONGVARBINARY?

    thanx...
    stefan

    Comment

    • info@daten-host.de

      #3
      Re: PreparedStateme nt

      sorry, I should write in english:

      I like to read VARBINARY-field from a table , save this ín a file and
      write it then into another table.
      I read the field with a select-statement and getString().
      The Result (like: 011b0148107f007 310850069006e01 671020205400550 149) i
      will insert with PreparedStateme nt:

      String value = new String();
      value = "011b0148107f00 7310850069006e0 167102020540055 0149";
      byte[] varByte = value.getBytes( );
      pstmt.setBytes( j, varByte);

      At that point i will get this error:
      com.ibm.db2.jcc .a.SqlException : DB2 SQL error: SQLCODE: -954, SQLSTATE:

      57011, SQLERRMC: null

      What is wrong?
      What is the difference in the setXXX-Statement with BINARY, VARBINARY,
      LONGVARBINARY?

      thanx...
      stefan

      Comment

      • Knut Stolze

        #4
        Re: PreparedStateme nt

        info@daten-host.de wrote:
        [color=blue]
        > sorry, I should write in english:
        >
        > I like to read VARBINARY-field from a table , save this ín a file and
        > write it then into another table.[/color]

        What's a VARBINARY? VARCHAR FOR BIT DATA or a BLOB?
        [color=blue]
        > I read the field with a select-statement and getString().
        > The Result (like: 011b0148107f007 310850069006e01 671020205400550 149) i[/color]

        First, what you're seeing there is the hexadecimal representation of the
        actual value, i.e. two of the digits together represent a single byte in
        the value.
        [color=blue]
        > will insert with PreparedStateme nt:
        >
        > String value = new String();
        > value = "011b0148107f00 7310850069006e0 167102020540055 0149";
        > byte[] varByte = value.getBytes( );
        > pstmt.setBytes( j, varByte);
        >
        > At that point i will get this error:
        > com.ibm.db2.jcc .a.SqlException : DB2 SQL error: SQLCODE: -954, SQLSTATE:
        >
        > 57011, SQLERRMC: null
        >
        > What is wrong?[/color]

        $ db2 "? sql0954"

        SQL0954C Not enough storage is available in the application heap
        to process the statement.

        Explanation:

        All available memory for the application has been used.

        The statement cannot be processed.

        User Response:

        Terminate the application on receipt of this message. Increase
        the database configuration parameter ( applheapsz ) to allow a
        larger application heap.

        sqlcode : -954

        sqlstate : 57011


        --
        Knut Stolze
        DB2 Information Integration Development
        IBM Germany

        Comment

        Working...