Reading data from database table that contains control characters. [message #505274] |
Sun, 01 May 2011 12:21 |
ziggy25
Messages: 206 Registered: July 2005
|
Senior Member |
|
|
I have the following bit of code that reads data from the an Oracle table (Note: This is running on Jdk 1.4.2)
ResultSet message = messageStatement.executeQuery(getMsgSql);
String messageData = message.getString("MESSAGE_DATA");
The data in the MESSAGE_DATA column contains text but also control characters that separate data elements in the message (i.e (char)31, (char)29) and (char)28) .
What i am finding is that for some reason message.getString() is sometimes truncating the message. I can read the majority of messages but some of them are truncated. Am i supposed to be reading the data using a different method? If so how?
I have tried to use sqlplus to look at the data in the database and it is all there it is just truncated by the message.getString() method. I saw this when i tried to output the result i.e. System.out.println(message.getString()).
I ran an sql query using the length() function in Oracle and length("MESSAGE_DATA") returns 2032 whereas in java message.getString(1).length() returns 2000. Im not sure why this is happening.
Thanks
[Updated on: Sun, 01 May 2011 12:22] Report message to a moderator
|
|
|
Re: Reading data from database table that contains control characters. [message #505275 is a reply to message #505274] |
Sun, 01 May 2011 12:23 |
ziggy25
Messages: 206 Registered: July 2005
|
Senior Member |
|
|
Ok i might be on to something i think. I just tried a newer version of the JDBC driver and it seems to be working. The driver that was being used on an older version that was delivered for the jdk1.4 delivery. Does anyone know why this is the case? And also, does using a newer version of the jdbc driver have any implications especially given the fact that the application is running on JDK 1.4. The oracle version is 10.1.0.3.0
Thanks
|
|
|
Re: Reading data from database table that contains control characters. [message #505277 is a reply to message #505275] |
Sun, 01 May 2011 13:12 |
ziggy25
Messages: 206 Registered: July 2005
|
Senior Member |
|
|
I am not sure if this is any helpfull but here are the versions of the two JDBC drivers.
The JDBC driver that does not work
===== Database info =====
DatabaseProductName: Oracle
DatabaseProductVersion: Oracle Database 10g Release 10.1.0.3.0 - 64bit Production
===== Driver info =====
DriverName: Oracle JDBC driver
DriverVersion: 8.0.5.2.0
DriverMajorVersion: 8
DriverMinorVersion: 0
The JDBC Driver that does work
===== Database info =====
DatabaseProductName: Oracle
DatabaseProductVersion: Oracle Database 10g Release 10.1.0.3.0 - 64bit Production
===== Driver info =====
DriverName: Oracle JDBC driver
DriverVersion: 10.2.0.1.0
DriverMajorVersion: 10
DriverMinorVersion: 2
|
|
|
|
|
|