• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SQL ResultSet

 
Anthony Smith
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to The JDBC Forum...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic