I have a table in PostgreSQL 8.4:
DROP TABLE filedata_temp;
CREATE TABLE filedata_temp
(
num serial NOT NULL,
id integer,
kadnum character(25),
deleted character(3),
the_geom geometry,
status_id integer,
CONSTRAINT filedata_temp_pkey PRIMARY KEY (num)
)
WITH (
OIDS=FALSE
);
ALTER TABLE filedata_temp OWNER TO postgres;
Simple data:

In java i do:
Class.forName("org.postgresql.Driver");
Connection ce= null;
ce = DriverManager.getConnection("jdbc:postgresql://localhost:5432/postgis","postgres","123456");
Statement se = null;
se = ce.createStatement();
Integer idn=null;
System.out.println("idnnull= "+idn);
ResultSet id=se.executeQuery("SELECT num FROM filedata_temp ORDER BY num DESC LIMIT 1");
while(id.next()){
idn=id.getInt("num");
System.out.println("query= "+idn);
}
if(idn==null){
idn=1;
}
ce.close();
se.close();
System.out.println("idn= "+idn);
And in console i get this:
idnnull= null
idn= 1
So i not get a System.out.println("query= "+idn); in console. Its mean that ResultSet is empty. But if i make this query in PostgreSQL i get a normal response. Whats wrong?
Result Set documentation says that method next returns true if the new current row is valid or false if there are no more rows.
So query result is not ok. Check your database connection, maybe you are connected to some other database which has empty table filedata_temp or some related problem.