aspose file tools*
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
Author

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:
(char)rs.getByte("ALL_CITIES_SERVED_FLG")
did not work...
I tried
(char)rs.getString("ALL_CITIES_SERVED_FLG")
did not work...
I tried
rs.getByte("ALL_CITIES_SERVED_FLG")
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: 15299
    
    6

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
Greenhorn

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
Sheriff

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


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
 
Consider Paul's rocket mass heater.
 
subject: SQL ResultSet