我有以下的JDBC代碼。請注意,我嘗試使用PostGIS的地理:PreparedStatement沒有讀取我所有的PostGIS地理參數
PreparedStatement stmt = db.prepareStatement("INSERT INTO " +
"source_imagery (image_path, boundary, image_time)" +
" VALUES (?, ST_GeographyFromText('POLYGON((" +
"? ?, ? ?, ? ?, ? ?))'), ?)");
stmt.setString(1, file.getAbsolutePath());
stmt.setDouble(2, bounds.getY());
stmt.setDouble(3, bounds.getX());
...
我得到以下異常的代碼的最後一行:
org.postgresql.util.PSQLException: The column index is out of range: 3, number of columns: 2.
我明白,它認爲我只有2個參數有,但你可以看到我打算有10個。我不確定它爲什麼不讀取POLYGON
內的任何參數。我知道,如果我直接在數據庫中使用它,這個SQL語句就可以工作,但我不確定爲了使它在我的Java代碼中工作而必須更改的內容。有任何想法嗎?
啊,我明白了。感謝您提供非常明確的解釋。我很感激。 – Steph