Results 1 to 2 of 2
  1. #1
    Chinnu55 is offline Member
    Join Date
    Apr 2011
    Posts
    20
    Rep Power
    0

    Default Getting exception when updating the table.

    Hi,

    I am using db2 database, when I am trying to update a table from java code
    i.e. using preparedStatement

    PreparedStatement prepStatement = conn.prepareStatement(updateValue);
    prepStatement.executeUpdate();

    updateValue is String which contians update sql query like "
    update WEB.USER set HR_CODE = 'Rationale Acct Mgr, kind of testing the lenght of value to update the DB2 database table' where ID = '1234' "

    even though the field length is 100 i.e. VARCHAR(100) in database. And length of the HR_CODE value 'Rationale Acct Mgr, kind of testing the lenght of value to update the DB2 database table' to update is 89 characters

    Getting exception:
    com.ibm.db2.jcc.a.SqlException: Value "Rationale Acct Mgr, kind of testing the lenght of value to " is too long.
    at com.ibm.db2.jcc.c.ig.d(ig.java(Compiled Code))
    at com.ibm.db2.jcc.a.kb.l(kb.java(Compiled Code))
    at com.ibm.db2.jcc.a.kb.a(kb.java(Compiled Code))
    at com.ibm.db2.jcc.a.w.a(w.java(Inlined Compiled Code))
    at com.ibm.db2.jcc.a.ec.b(ec.java(Compiled Code))
    at com.ibm.db2.jcc.c.jg.db(jg.java(Inlined Compiled Code))
    at com.ibm.db2.jcc.c.jg.d(jg.java(Compiled Code))
    at com.ibm.db2.jcc.c.jg.Y(jg.java(Compiled Code))
    at com.ibm.db2.jcc.c.jg.executeUpdate(jg.java(Compile d Code))
    at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement. pmiExecuteUpdate(WSJdbcPreparedStatement.java(Comp iled Code))
    at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement. executeUpdate(WSJdbcPreparedStatement.java(Compile d Code))

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Varchar 100 bytes? or characters? I don't know about DB2, but, at least with oracle, that designation makes a difference when using a unicode character set (or another encoding that using multibyte characters), and per default it is bytes, in which case that String is 178 bytes long (if not, as in Oracle, 356 bytes long), but the field would only allow 100.

Similar Threads

  1. Hyperlink on a refreshing table throws exception
    By preeta in forum AWT / Swing
    Replies: 1
    Last Post: 04-12-2011, 06:55 PM
  2. Updating my gui
    By mrx89_7 in forum New To Java
    Replies: 4
    Last Post: 02-09-2011, 05:33 AM
  3. Replies: 1
    Last Post: 01-08-2010, 06:19 AM
  4. Updating Displayed Table Rows
    By raycini in forum JavaServer Faces (JSF)
    Replies: 2
    Last Post: 04-20-2009, 08:24 AM
  5. Updating database table from JTable
    By yesjava in forum New To Java
    Replies: 1
    Last Post: 08-16-2008, 10:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •