use of org.teiid.jdbc.TeiidConnection in project teiid by teiid.
the class GeometryTransformUtils method lookupProj4Text.
/**
* Lookup proj4 parameters in SPATIAL_REF_SYS using SRID as key.
*
* @param ctx
* @param srid
* @return
* @throws FunctionExecutionException
*/
public static String lookupProj4Text(CommandContext ctx, int srid) throws FunctionExecutionException {
String projText;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
TeiidConnection conn = ctx.getConnection();
// $NON-NLS-1$
pstmt = conn.prepareStatement("select proj4text from SYS.spatial_ref_sys where srid = ?");
pstmt.setInt(1, srid);
rs = pstmt.executeQuery();
if (!rs.next()) {
throw new FunctionExecutionException(QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31162, srid));
}
projText = rs.getString(1);
} catch (SQLException e) {
throw new FunctionExecutionException(e, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31163));
} finally {
try {
if (rs != null) {
rs.close();
}
} catch (Exception e) {
// ignore
}
try {
if (pstmt != null) {
pstmt.close();
}
} catch (Exception e) {
// ignore
}
}
return projText;
}
Aggregations