I have a oracle table defined like this:
create table image_table_test (id number primary key, image ordsys.ordimage);
when I try to select maximum ID value in that table and return it in java variable, using the code below, it returns a zero value, but the value in a table is set to 1. the rsx.getInt("ID");
method isn't returning an integer value from a table.
my table When I execute SELECT MAX(ID) as ID FROM image_table_test;
:
ID
1
my java code:
Statement stmt;
try{
stmt = conn.createStatement();
String maxIdStr = "";
int maxIdNum = 0;
String maxIdSQL = "SELECT MAX(ID) as ID FROM image_table_test";
ResultSet rsx = stmt.executeQuery(maxIdSQL);
while(rsx.next()){
maxIdNum = rsx.getInt("ID"); // Here the value is passed as 0
}
maxIdNum = maxIdNum + 1;
maxIdStr = Integer.toString(maxIdNum);
System.out.println(maxIdStr);
rsx.close();
stmt.close();
I would appreciate your help if you know why is this happening?