/** * @see stream.AbstractProcessor#finish() */ @Override public void finish() throws Exception { super.finish(); log.debug("Closing SQL writer, {} items written.", count); log.debug("Closing SQL connection..."); connection.close(); this.tableSchema = null; } }
public boolean hasTable(String name) { if (tableExists) return true; tableExists = super.hasTable(name); return tableExists; }
protected boolean hasTable(String name) { Statement stmt = null; boolean tableExists = false; Connection con = null; try { con = openConnection(); stmt = con.createStatement(); ResultSet rs = stmt.executeQuery("SELECT COUNT(*) FROM " + name); if (rs.next()) { tableExists = true; } rs.close(); } catch (Exception e) { log.error("Error: {}", e.getMessage()); } finally { try { stmt.close(); } catch (Exception e) { } } close(con); return tableExists; } }
/** * @see stream.AbstractProcessor#init(stream.ProcessContext) */ @Override public void init(ProcessContext ctx) throws Exception { super.init(ctx); if (table == null || table.trim().equals("")) throw new Exception("No 'table' attribute provided!"); init(); log.debug("init(ProcessContext) done."); }
protected boolean createTable(String name, Map<String, Class<?>> types) { String create = dialect.getCreateTableCommand(name, types); log.debug("Trying to create table '{}':\n{}", name, create); try { Connection con = openConnection(); Statement stmt = con.createStatement(); log.debug("Running create: {}", create); int rc = stmt.executeUpdate(create); log.debug("create returned: {}", rc); stmt.close(); con.close(); return true; } catch (Exception e) { e.printStackTrace(); return false; } }
protected boolean hasTable(String name) { Statement stmt = null; boolean tableExists = false; Connection con = null; try { con = openConnection(); stmt = con.createStatement(); ResultSet rs = stmt.executeQuery("SELECT COUNT(*) FROM " + name); if (rs.next()) { tableExists = true; } rs.close(); } catch (Exception e) { log.error("Error: {}", e.getMessage()); } finally { try { stmt.close(); } catch (Exception e) { } } close(con); return tableExists; } }
/** * @see stream.AbstractProcessor#init(stream.ProcessContext) */ @Override public void init(ProcessContext ctx) throws Exception { super.init(ctx); if (table == null || table.trim().equals("")) throw new Exception("No 'table' attribute provided!"); init(); log.debug("init(ProcessContext) done."); }
protected boolean createTable(String name, Map<String, Class<?>> types) { String create = dialect.getCreateTableCommand(name, types); log.debug("Trying to create table '{}':\n{}", name, create); try { Connection con = openConnection(); Statement stmt = con.createStatement(); log.debug("Running create: {}", create); int rc = stmt.executeUpdate(create); log.debug("create returned: {}", rc); stmt.close(); con.close(); return true; } catch (Exception e) { e.printStackTrace(); return false; } }
protected boolean hasTable(String name) { Statement stmt = null; boolean tableExists = false; Connection con = null; try { con = openConnection(); stmt = con.createStatement(); ResultSet rs = stmt.executeQuery("SELECT COUNT(*) FROM " + name); if (rs.next()) { tableExists = true; } rs.close(); } catch (Exception e) { log.error("Error: {}", e.getMessage()); } finally { try { stmt.close(); } catch (Exception e) { } } close(con); return tableExists; } }
public boolean hasTable(String name) { if (tableExists) return true; tableExists = super.hasTable(name); return tableExists; }
/** * @see stream.AbstractProcessor#finish() */ @Override public void finish() throws Exception { super.finish(); log.debug("Closing SQL writer, {} items written.", count); log.debug("Closing SQL connection..."); connection.close(); this.tableSchema = null; } }
/** * @see stream.AbstractProcessor#init(stream.ProcessContext) */ @Override public void init(ProcessContext ctx) throws Exception { super.init(ctx); if (table == null || table.trim().equals("")) throw new Exception("No 'table' attribute provided!"); init(); log.debug("init(ProcessContext) done."); }
protected boolean createTable(String name, Map<String, Class<?>> types) { String create = dialect.getCreateTableCommand(name, types); log.debug("Trying to create table '{}':\n{}", name, create); try { Connection con = openConnection(); Statement stmt = con.createStatement(); log.debug("Running create: {}", create); int rc = stmt.executeUpdate(create); log.debug("create returned: {}", rc); stmt.close(); con.close(); return true; } catch (Exception e) { e.printStackTrace(); return false; } }
public boolean hasTable(String name) { if (tableExists) return true; tableExists = super.hasTable(name); return tableExists; }
/** * @see stream.AbstractProcessor#finish() */ @Override public void finish() throws Exception { super.finish(); log.debug("Closing SQL writer, {} items written.", count); log.debug("Closing SQL connection..."); connection.close(); this.tableSchema = null; } }