File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Retrieving LONGVARCAR data type from SQL Server

 
martin rolph
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I've got a recordset from a Query in a SQL Server db. What I'm trying to do is just print out the columns. All is fine when the data types are CHAR or INT but things go wrong when it is LONGVARCHAR (text field in MS SQL). When I try to print out the result I just get the text value as hexadecimal code. I've tried to use:
recordSet.getString("field") and recordSet.getAsciiStream("field") and recordSetCharacterStream("field") but all return the text as hexadecimal.
I've tried lots of difference readers, such as


Does anyone know how I can convert the Hex to ASCII?
 
martin rolph
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I finally found the answer. I had to do this

but I don't know why this works!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic