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...
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.
Larry Jones
Greenhorn
Joined: Oct 22, 2002
Posts: 24
posted
0
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.