This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes getCharacterStream puzzler Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "getCharacterStream puzzler" Watch "getCharacterStream puzzler" New topic
Author

getCharacterStream puzzler

Dave Bender
Greenhorn

Joined: Oct 16, 2003
Posts: 3
Why does the ResultSet.getCharacterStream().read method return an int instead of a Character?
It seems that that requires me to make the conversion of a number to a character, which aside from being error-prone, bypasses all the great character set translation stuff built into Java, doesn't it?
I'm interested in this topic mostly because I've got a problem with a JDBC driver returning question marks for certain extended characters and it seems like it has something to do with the number-to-character conversion.
Any insight, particularly on ways to make the conversion correctly, would be appreciated. I've got windows-1252 characters from Windows machines being stored as UNICODE characters (MS Access 2000; memo field) and they seem to be getting converted when they go through my servlet and JDBC driver to ISO-8859-1 characters. So many extended charcters, like the en- and em-dash characters, get turned into question marks.
Dave
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8839
    
    7

Originally posted by Dave Bender:
Why does the ResultSet.getCharacterStream().read method return an int instead of a Character?
Dave

Because it returns an instance of java.io.Reader. By returning the onen of the lowest-level objects in the IO hierarchy it gives you great flexability with how you implement your code. Java IO streams are very powerful, but not very intuitive. I suggest you check out this
tutorial for more information. In your case you probably want to create an instance of BufferedReader using the ResultSet.getCharacterStream() and use the readLine() method to read a memo field.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getCharacterStream puzzler
 
Similar Threads
Byte streams and the super keyword
Eclipse , syntax error on token(s)
printing Extended Character Set values
Weird Characters in UTF-8 web pages
JDBC unicode conversion issue