File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes SQL ResultSet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "SQL ResultSet" Watch "SQL ResultSet" New topic

SQL ResultSet

Anthony Smith
Ranch Hand

Joined: Sep 10, 2001
Posts: 285
I am trying to store a value from my db into an
char variable but do not know how to do so.
I tried:
did not work...
I tried
did not work...
I tried
did not work...
It is just a char stuck in a db that I want to know fetch and store in a char variable...
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302

Well, first off, you are posting in the wrong forum. There is a JDBC forum for this.
And to answer you question, it kind of depends on what data type you stored it as in the DB.
But the easiest why would probably be to do:
char foo = (char)rs.getObject("Column Name");
That would probably work.

GenRocket - Experts at Building Test Data
Larry Jones

Joined: Oct 22, 2002
Posts: 24
You can't cast a String to a char like that.
This will work:
String myS = "r";
char myC;
myC = myS.CharAt(0);
This will "cast" a String to an char.
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
Moving this to The JDBC Forum...

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
I agree. Here's the link:
subject: SQL ResultSet
It's not a secret anymore!