This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes Reading data from database table that contains control characters. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Reading data from database table that contains control characters." Watch "Reading data from database table that contains control characters." New topic
Author

Reading data from database table that contains control characters.

O. Ziggy
Ranch Hand

Joined: Oct 02, 2005
Posts: 430

Ok i am completely stuck with this one. I have the following bit of code that reads data from the an Oracle table (Note: This is running on Jdk 1.4.2)



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

ps. Also posted on http://forums.oracle.com/forums/post!default.jspa?forumID=922
O. Ziggy
Ranch Hand

Joined: Oct 02, 2005
Posts: 430

Update
---

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
O. Ziggy
Ranch Hand

Joined: Oct 02, 2005
Posts: 430



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



The JDBC Driver that does work

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

Excellent work on finding the solution yourself, and thanks for sharing it with us!

I'll move this thread to our JDBC forum so anybody who encounters the same problem in the future can find it a little bit faster.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
Consider Paul's rocket mass heater.
 
subject: Reading data from database table that contains control characters.
 
Similar Threads
validating multibyte characters
Converting a String to Clob for insert into DB
How to retreive a blob....
korean characters handling
problem with outputText in datatable