public DBLibConnection(Connection con, CachedDataSource dataSource) { this.connection = con; this.dataSource = dataSource; locked = false; dataSource.getPoolInfo(true); }
public boolean unlock() { dataSource.unlockTable(connection); locked = false; return false; }
public boolean lockTable(String tablename) { this.tableName = tablename; locked = dataSource.lockTable(connection, tableName); return locked; }
public Connection getConnection() throws SQLException { return(dbSvc.getConnection()); }
public CachedRowSet getData(String statement, List<String> arguments) throws Throwable { ArrayList<Object> newList = new ArrayList<>(); if (arguments != null && !arguments.isEmpty()) { newList.addAll(arguments); } resetInactivityTimer(); return dataSource.executePreparedStatement(connection, statement, newList, false); }
public boolean writeData(String statement, List<String> arguments) throws Throwable { ArrayList<Object> newList = new ArrayList<>(); if (arguments != null && !arguments.isEmpty()) { newList.addAll(arguments); } resetInactivityTimer(); return dataSource.executeUpdatePreparedStatement(connection, statement, newList, false); }
@Override public CachedRowSet getData(String statement, ArrayList<String> arguments, String preferredDS) throws SQLException { ArrayList<Object> newList= new ArrayList<>(); if(arguments != null && !arguments.isEmpty()) { newList.addAll(arguments); } if(recoveryMode) return requestDataWithRecovery(statement, newList, preferredDS); else return requestDataNoRecovery(statement, newList, preferredDS); }
@Override public void close() throws SQLException { if (this.locked) { try { this.unlock(); } catch (Exception th) { LOGGER.error("Failed unlocking", th); } } if (connection != null && !connection.isClosed()) { connection.close(); } dataSource.getPoolInfo(false); }
protected boolean testConnection() { return testConnection(false); }
public static boolean updateDB(String tableName, List<String> argList, String whereClause, String setCluase) throws SQLException { String updatePasswordString = "update " + tableName + " set " + setCluase + " where " + whereClause; return jdbcDataSource.writeData(updatePasswordString, Lists.newArrayList(argList), Constants.SCHEMA_SDNCTL); }
public DBResourceManager(final DBLIBResourceProvider configuration) { this(configuration.getProperties()); }
public static CachedRowSet getData(String tableName, List<String> argList, String schema, String getselectData, String getDataClasue) throws SQLException { String selectQuery = "select " + getselectData + "from " + tableName + " where " + getDataClasue; return jdbcDataSource.getData(selectQuery, Lists.newArrayList(argList), schema); }
@Override public int getLoginTimeout() throws SQLException { return this.dsQueue.first().getLoginTimeout(); }
@Override public PrintWriter getLogWriter() throws SQLException { return this.dsQueue.first().getLogWriter(); }
@Override public void setLogWriter(PrintWriter out) throws SQLException { this.dsQueue.first().setLogWriter(out); }
@Override public void setLoginTimeout(int seconds) throws SQLException { this.dsQueue.first().setLoginTimeout(seconds); }
@Override public boolean writeData(String statement, ArrayList<String> arguments, String preferredDS) throws SQLException { ArrayList<Object> newList= new ArrayList<>(); if(arguments != null && !arguments.isEmpty()) { newList.addAll(arguments); } return writeDataNoRecovery(statement, newList, preferredDS); }
@Override public void run() { CachedDataSource ds = dsQueue.first(); if(ds != null) ds.getPoolInfo(false); } }
public void setDataSource(CachedDataSource dataSource) { if(this.dsQueue.contains(dataSource)) return; if(this.broken.contains(dataSource)) return; if(dataSource.testConnection(true)){ this.dsQueue.add(dataSource); } else { this.broken.add(dataSource); } }
public static boolean deleteData(String tableName, List<String> argList) throws SQLException { String deleteQuery = "delete from " + tableName; log.info(deleteQuery); return jdbcDataSource.writeData(deleteQuery, Lists.newArrayList(argList), Constants.SCHEMA_SDNCTL); }