2

When I execute a query using PreparedStatement.executeQuery() from a Java application I get a resultSet object with wrong values for some of the fields. When I use PLSQL developer then the value looks ok.

The field value is 10101010 but in the resultSet it's 1$ffssff. The database field size is only 8 bytes but the result value I get is 9 bytes (and totally wrong). The type for this field is VARCHAR2(8 BYTE)

This only happens sometimes. Other times when I execute the same query I get the correct value.

How is it possible that resultSet fetches the wrong value for some of the fields ? Are there some settings I need to verify for this? My NLS_RDBMS_VERSION is 11.2.0.3.0.

Do you think it's a Java side problem or Oracle side data fetching problem?

Please let me know if you need additional details.

Jan
  • 5,688
  • 3
  • 27
  • 44
saumil
  • 21
  • 1
  • If you can run the query over and over again in SQL developer and keep getting the correct results then you have a java issue of some kind. Not aware of any bugs on the Oracle side. Usually these are type conversion or code page issues. – TheMadDBA Jul 07 '15 at 16:50
  • 2
    Can you show your Java code, and version, in case you're just doing something slightly wrong? – Alex Poole Jul 07 '15 at 17:15
  • protected ResultSet exePreparedQuery(Connection conn, String query, ArrayList params) { PreparedStatement stmt = null; ResultSet rs = null; try { stmt = conn.prepareStatement(query); bindParametersValues(stmt, query, params); rs = stmt.executeQuery(); catch (Exception e) { e.printStackTrace(); } return rs; } – saumil Jul 07 '15 at 20:08
  • Hi TheMadDBA -- if it is code page page issues then it should be consistence, right? In my case it happened only some times... – saumil Jul 07 '15 at 20:20
  • Java version is 1.6.0_23 – saumil Jul 07 '15 at 20:21

0 Answers0