This method closed the result set "safely" in that it never throws an exception. Any exceptions that do occur are logged at {@link Level#FINER}.
103104105106107108109110111112113
} catch(SQLException e) { System.out.println("Failed to check if the user has database creation privileges and postgis is an available extension"); e.printStackTrace(); return false; } finally { closer.closeSafe(rs); closer.closeSafe(cx); closer.closeSafe(st); } }
104105106107108109110111112113114
System.out.println("Failed to check if the user has database creation privileges and postgis is an available extension"); e.printStackTrace(); return false; } finally { closer.closeSafe(rs); closer.closeSafe(cx); closer.closeSafe(st); } } public void testCreateDrop() throws IOException, SQLException, SchemaException {
105106107108109110111112113114115
e.printStackTrace(); return false; } finally { closer.closeSafe(rs); closer.closeSafe(cx); closer.closeSafe(st); } } public void testCreateDrop() throws IOException, SQLException, SchemaException { PostgisNGDataStoreFactory factory = new PostgisNGDataStoreFactory();
202203204205206207208209210211212
try { cx = ds.getConnection(); } catch (SQLException e) { canConnect = false; } finally { closer.closeSafe(cx); } if (!canConnect) { // get the connection params String host = (String) HOST.lookUp(params);
228229230231232233234235236237238
st = cx.createStatement(); st.execute(sql); } catch (SQLException e) { throw new IOException("Failed to create the target database", e); } finally { closer.closeSafe(st); closer.closeSafe(cx); } // if we got here the database has been created, now verify it has the postgis // extensions
229230231232233234235236237238239
st.execute(sql); } catch (SQLException e) { throw new IOException("Failed to create the target database", e); } finally { closer.closeSafe(st); closer.closeSafe(cx); } // if we got here the database has been created, now verify it has the postgis // extensions // and eventually try to create them
252253254255256257258259260261262
st.execute("create extension postgis"); } } catch (SQLException e) { throw new IOException("Failed to create the target database", e); } finally { closer.closeSafe(st); closer.closeSafe(cx); } // and finally re-create the connection pool ds = super.createDataSource(params, dialect);
253254255256257258259260261262263
} } catch (SQLException e) { throw new IOException("Failed to create the target database", e); } finally { closer.closeSafe(st); closer.closeSafe(cx); } // and finally re-create the connection pool ds = super.createDataSource(params, dialect); }
303304305306307308309310311312313
st = cx.createStatement(); st.execute(sql); } catch (SQLException e) { throw new IOException("Failed to drop the target database", e); } finally { closer.closeSafe(st); closer.closeSafe(cx); } }
304305306307308309310311312313314
st.execute(sql); } catch (SQLException e) { throw new IOException("Failed to drop the target database", e); } finally { closer.closeSafe(st); closer.closeSafe(cx); } }