gvSIG bugs #2411
No se cierran las conexiones en el metodo getPostgistVersion de PostgreSQLHelper
| Status: | Closed | % Done: | 0% | |
|---|---|---|---|---|
| Priority: | Normal | Spent time: | - | |
| Assignee: | ||||
| Category: | Database | |||
| Target version: | 2.1.0-2221-testing | |||
| Severity: | Add-on version: | |||
| gvSIG version: | 2.1.0 | Add-on build: | ||
| gvSIG build: | Add-on resolve version: | |||
| Operative System: | Add-on resolve build: | |||
| Keywords: | Proyecto: | |||
| Has patch: | Yes | Hito: | ||
| Add-on name: | Unknown |
Description
private int[] getPostgisVersion() {
String sql = "SELECT PostGIS_Lib_Version()";
ResultSet rs = null;
Statement st = null;
String v = null;
Connection conn = null;
try {
conn = this.getConnection();
st = conn.createStatement();
rs = st.executeQuery(sql);
rs.next();
v = rs.getString(1);
if (v == null) {
throw new Exception("Returned version is NULL");
}
} catch (Exception exc) {
logger.error("Unable to get Postgis version: " + exc.getMessage(), exc);
return null;
} finally {
try { rs.close(); } catch (Exception e) {};
try { st.close(); } catch (Exception e) {};
try { conn.close(); } catch (Exception e) {};
}
String[] vv = v.split("\\.");
int[] resp = new int[3];
try {
for (int i=0; i<3; i++) {
resp[i] = Integer.parseInt(vv[i]);
}
} catch (Exception exc) {
logger.error("Unable to parse version: " + v, exc);
return null;
}
return resp;
}
History
#1
Updated by Juan Lucas Domínguez about 12 years ago
- Assignee changed from Joaquín del Cerro Murciano to Juan Lucas Domínguez
#2
Updated by Juan Lucas Domínguez about 12 years ago
- Status changed from New to Fixed
Closing connection after getting Postgis version (patch provided by fdiaz).
#3
Updated by Álvaro Anguix about 12 years ago
- Status changed from Fixed to Closed