I have been doing CRUD operation on database, but i could not find any direct method for the getting the data type char
in database.
Though i achieved the output using the getString(String column_name)
of the result set, but i wonder why there does not exist any method like getChar(String column_name)
, since String and Character are two different data types.
As MySQL sees it, it's all Strings
because it has no type for a single character. Sure, you can set CHAR
or VARCHAR
to sizes of max one, but this is a special case and you generally don't want to make methods for special cases when the functionality is already there.
Just extract the Java char
from the resulting String
, as such:
getString(column_name).charAt(0)