PreparedStatement setString(…) for all, even if corrsponding data type is an integer

后端 未结 2 1203
南方客
南方客 2020-12-19 05:33

I have come across the following codes i feel it is doing the wrong thing:

(Note that this is JDK 1.4.2, therefore the list is not typed)

StringBuffe         


        
2条回答
  •  长情又很酷
    2020-12-19 05:49

    This didn't help me. Below is the query built after appending the bind variables. select ACC_NO from ACC_TABLE where ACC_NAME='java.lang.String';

    It is trying to convert to java.lang.String type and which results in the following exception java.sql.SQLException: Could not execute sql command - Original message: null

    Where as my ACC_NAME is 'user01'. So actually the query should be some thing like this, select ACC_NO from ACC_TABLE where ACC_NAME='user01';

    So if my understanding is not wrong, preparedStatement.setObject(index, object) is converting the data to its respective data type and setting it.

    preparedStatement.setObject(index, object) in MySQL is working perfectly alright with no issues. Only problem is while using Oracle. Oracle DB version i am working with is

    Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production PL/SQL Release 11.2.0.2.0 - Production "CORE 11.2.0.2.0 Production" TNS for 32-bit Windows: Version 11.2.0.2.0 - Production NLSRTL Version 11.2.0.2.0 - Production

提交回复
热议问题