我打電話我的Java EE代碼PostgreSQL的功能,但它不返回任何東西在那裏。(它在SQL查詢結果)在Java EE中的CallableStatement不返回從PostgreSQL函數什麼
public List<Integer> convertIdsToLats12(Integer src, Integer dest) {
List<Integer> ids = new ArrayList<Integer>();
ResultSet resultSet = null;
try {
Context ctx = new InitialContext();
DataSource source = (DataSource) ctx.lookup("java:/RoutingDS");
Connection connection = source.getConnection();
CallableStatement statement = connection
.prepareCall("{ ? = call pgr_astar(?, ?, ?, ?, ?) }");
statement
.setString(
2,
"SELECT gid AS id, source::integer, target::integer, length::double precision AS cost, x1, y1, x2, y2 FROM waysF");
statement.setObject(3, src);
statement.setObject(4, dest);
statement.setBoolean(5, false);
statement.setBoolean(6, false);
statement.registerOutParameter(1, Types.OTHER);
System.out.println("*************AVANT");
statement.execute();
System.out.println("*************APRES");
resultSet = (ResultSet) statement.getObject(1);
while (resultSet.next()) {
ids.add((Integer) resultSet.getObject(2));
}
resultSet.close();
statement.close();
} catch (Exception e) {
// TODO: handle exception
}
return ids;
}
這是我的方法,它有什麼問題嗎?
沒有'JEE'這樣的東西 - 我認爲你的意思是JavaEE?你究竟使用什麼 - 應用服務器/框架和版本,PostgreSQL版本,PgJDBC版本。另外,你看過PostgreSQL服務器錯誤日誌嗎? – 2014-09-07 10:47:14