我在 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;
简单数据:
在java中我做:
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);
在控制台中我得到了这个:
idnnull= null
idn= 1
所以我没有得到System.out.println("query= "+idn);
控制台。这意味着 ResultSet 是空的。但是如果我在 PostgreSQL 中进行这个查询,我会得到一个正常的响应。怎么了?