Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getCharacterStream puzzler

 
Dave Bender
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 9265
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic