java - DB2 jdbc SQL Error: SQLCODE=-302, SQLSTATE=22001 on Select -
there select query executing db2 jdbc. using prepared statement pass in value parameter. column length of parameter in database 12 works fine until length of value 12 , fails. throws exception error message in title. did searching , found explanation in following link http://www-01.ibm.com/support/docview.wss?uid=swg21319477 , resolution mentioned in there below
resolving problem add additional client side validation code prevents queries, values larger allowed maximum length ran.
i don't want this. why wouldn't query return no results. idea how go this?
edit
string sql = "select student_id, student_name student student_id = ?"; try (connection connection = dbutils.getconnection) { try (preparedstatement statement = connection.preparestatement(sql)) { statement.setstring(1, student_id); resultset result = statement.executequery(); while (result.next()) { //... } } }
i going answer question:
why wouldn't query return no results. idea how go this?
computer programs including database management systems use errors , warnings indicate went wrong, used in wrong way or situations possible conflicts or "danger" encountered. in case trying call defined api value not fit. program refuses accept value , points out wrong call returning error code.
if return no results, how know api call, usage, wrong? know , can fix it. or using exception handling ignore , move on...
Comments
Post a Comment