If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > DB2 Select query with prepared statement.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-24-10, 07:38
bulutoprak bulutoprak is offline
Registered User
 
Join Date: Aug 2010
Posts: 1
DB2 Select query with prepared statement.

Hi Guys,
I have a problem with DB2 when I am executing a select query which takes parameters with prepared statement. In the example below, 4th parameter has column size of 8, but i am giving string longer than that. I know it is not right but i dont want db2 to give an exception for that. Instead, I am expecting a 0 result. If i run the sql directly without using prepared statement it works fine and returns 0 result. Is it possible to override this behavior of db2 driver by may be setting a system parameter?
Thanks for the answers in advance.



PreparedStatement stmt = conn.prepareStatement(strQuery);
stmt.setString(4, "71111111111111111111111111111111111111111");
ResultSet query = stmt.executeQuery();


Gets the exception:
Exception in thread "main" com.ibm.db2.jcc.a.wm: DB2 SQL Error: SQLCODE=-302, SQLSTATE=22001, SQLERRMC=null, DRIVER=3.51.90
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On