First return the result to ResultSet rs, then you can write the code as shown below.
You can check an instance of an object and assign a value.
String str;
Object obj = (Object)rs.getObject(1);
if(obj instanceof String){
str=(String)obj;
}
else if (obj instanceof Integer){
}
// same thing you can do for other types
source
share