/** * drops tables, statement oder defined by * {@link #getOrderedNamesForDrop()} * * @throws IOException */ public void dropTables() throws IOException { Connection con = null; PreparedStatement ps = null; try { con = getConnection(); for (String stmt : getOrderedNamesForDrop()) { ps= getDDLStatement(stmt, con); ps.execute(); ps.close(); } } catch (SQLException ex) { throw new IOException(ex); } finally { closeFinally(con, ps, null); } }
/** * Check DML statements using * {@link #checkSQLStatements(Properties)} * * @throws IOException */ public Map<String,SQLException> checkDMLStatements() throws IOException { return checkSQLStatements(dmlProps); }
/** * get a prepared DDL statement for a property key * * @param key * @param con * @return * @throws IOException * @throws SQLException */ protected PreparedStatement getDDLStatement (String key,Connection con) throws IOException,SQLException { return getJDBCStatement (key,ddlProps,con ); }
/** * create tables and indexes, statement order * defined by {@link #getOrderedNamesForCreate()} * * @throws IOException */ public void createTables() throws IOException { Connection con = null; PreparedStatement ps = null; try { con = getConnection(); for (String stmt : getOrderedNamesForCreate()) { ps= getDDLStatement(stmt, con); ps.execute(); ps.close(); } } catch (SQLException ex) { throw new IOException(ex); } finally { closeFinally(con, ps, null); } }
public void createTablesIfRequired(JDBCSecurityServiceConfig config) throws IOException{ if (this.canCreateStore()==false) return; if (config.isCreatingTables()==false) return; if (tablesAlreadyCreated()) return; Connection con = null; PreparedStatement ps = null; try { con = datasource.getConnection(); if (con.getAutoCommit()==true) con.setAutoCommit(false); con = getConnection(); for (String stmt : getOrderedNamesForCreate()) { ps= getDDLStatement(stmt, con); ps.execute(); ps.close(); } con.commit(); } catch (SQLException ex) { throw new IOException(ex); } finally { closeFinally(con, ps, null); } }
public static void dropExistingTables(AbstractJDBCService service,Connection con) throws IOException { PreparedStatement ps = null; try { for (String stmt : service.getOrderedNamesForDrop()) { try { ps= service.getDDLStatement(stmt, con); ps.execute(); ps.close(); } catch (SQLException ex) { //ex.printStackTrace(); } } con.commit(); } catch (SQLException ex) { throw new IOException(ex); } finally { try { if (ps!=null) ps.close(); } catch (SQLException ex) {}; } }
/** * Get a new connection from the datasource, * check/set autocommit == false and isolation level * according to {@link #DEFAULT_ISOLATION_LEVEL} * * @return * @throws SQLException */ protected Connection getConnection() throws SQLException{ Connection con = getDataSource().getConnection(); if (con.getAutoCommit()) con.setAutoCommit(false); if (con.getTransactionIsolation()!=DEFAULT_ISOLATION_LEVEL) con.setTransactionIsolation(DEFAULT_ISOLATION_LEVEL); return con; }
Connection con = null; try { con = getConnection(); for (Object key : props.keySet()) { String stmt = props.getProperty(key.toString()).trim(); throw new IOException(ex); } finally { closeFinally(con, null,null);
Connection con=null; try { con=getConnection(); DatabaseMetaData md = con.getMetaData(); String schemaName=null; rs.close(); if (con!=null) closeConnection(con); } catch (SQLException e) {
/** * helper method, if any of the parametres * is not null, try to close it and throw * away a possible {@link SQLException} * * @param con * @param ps * @param rs */ protected void closeFinally(Connection con, PreparedStatement ps, ResultSet rs) { try { if (rs!=null) rs.close(); } catch (SQLException ex) {} try { if (ps!=null) ps.close(); } catch (SQLException ex) {} try { if (con!=null) closeConnection(con); } catch (SQLException ex) {} }
public static void dropExistingTables(AbstractJDBCService service, Connection con) throws IOException { PreparedStatement ps = null; try { for (String stmt : service.getOrderedNamesForDrop()) { try { ps = service.getDDLStatement(stmt, con); ps.execute(); ps.close(); } catch (SQLException ex) { // ex.printStackTrace(); } } con.commit(); } catch (SQLException ex) { throw new IOException(ex); } finally { try { if (ps != null) ps.close(); } catch (SQLException ex) { } ; } }
protected static void dropExistingTables(AbstractJDBCService service) throws IOException { Connection con = null; try { con = service.getDataSource().getConnection(); dropExistingTables(service,con); } catch (SQLException ex) { throw new IOException(ex); } finally { try { if (con != null) con.close();} catch (SQLException ex) {};; } }
public static void dropExistingTables(AbstractJDBCService service) throws IOException { Connection con = null; try { con = service.getDataSource().getConnection(); dropExistingTables(service, con); } catch (SQLException ex) { throw new IOException(ex); } finally { try { if (con != null) con.close(); } catch (SQLException ex) { } ;; } }
/** * get a prepared DML statement for a property key * * @param key * @param con * @return * @throws IOException * @throws SQLException */ protected PreparedStatement getDMLStatement (String key,Connection con) throws IOException,SQLException { return getJDBCStatement (key,dmlProps,con ); }
/** * Check DDL statements using * {@link #checkSQLStatements(Properties)} * * @throws IOException */ public Map<String,SQLException> checkDDLStatements() throws IOException { return checkSQLStatements(ddlProps); }