1
我有PostgreSQL + PostGIS。如何在java中調用PostgreSQL函數?
我java的我想打電話給這個查詢:
SELECT num,id,mydata, asText(the_geom) FROM filedata
但得到NullPointerExeption。
我認爲它在這個查詢中嘗試調用函數asText
並做錯了。我該怎麼辦?
UPDATE
這是我的代碼:
IndexedContainer container = createContainer("SELECT num,id,mydata, asText(the_geom) FROM filedata");
public IndexedContainer createContainer(String SQL) throws SQLException, ClassNotFoundException
{
Class.forName("org.postgresql.Driver");
Connection con= null;
con = DriverManager.getConnection("jdbc:postgresql://localhost:5432/postgis","postgres","123456");
IndexedContainer container = new IndexedContainer();
String sSQL = SQL;
PreparedStatement ps = con.prepareStatement(sSQL);
////*****////
}
'NullPointerException'永遠不會含糊不清。檢查堆棧跟蹤(如有必要,然後遍歷代碼)以查看空值。然後找出原因。 – keyser
顯示更多代碼。你如何執行SQL查詢? – gefei
您將需要顯示相關的Java代碼。 –