org.postgresql.util.PSQLException 处理记录

创建带geomtry类型字段的表,代码如下:

String sql = "create table " + tableName + " (id Int4,geom geometry);";
Connection connection = null;
Statement statement = null;
try {  
    Class.forName(driver);
    connection = DriverManager.getConnection(url, userName, password);
    statement = connection.createStatement();
    statement.execute(sql);
    return true;
} catch (Exception e) {
    e.printStackTrace();
    return false;
} finally {
    try {
        statement.close();
        connection.close();
    } catch (SQLException e) {
        e.printStackTrace();
    }
}

调试过程,报异常org.postgresql.util.PSQLException : type geometry does not exist。

解决办法:geometry前加“public.” 创建语句写为:String sql = "create table " + tableName + " (id Int4,geom public.geometry);";

你可能感兴趣的:(gis,opengis)