List of utility methods to do JDBC Reds Connection
void | createRedshiftTable(String redshiftURL, Properties loginProperties, String tableName, List Helper method to create a Amazon Redshift table Connection conn = DriverManager.getConnection(redshiftURL, loginProperties); Statement stmt = conn.createStatement(); stmt.execute("CREATE TABLE " + tableName + " " + toSQLFields(fields) + ";"); stmt.close(); conn.close(); |
boolean | checkConnection() Checks if connection is supposed to be present and attempts to reconnect if there was previously an error. if (connection != null) { return (!errorCondition) || connect(userName, password); return false; |
boolean | checkConnection() Checks if connection is supposed to be present and attempts to reconnect if there was previously an error. if (connection != null) { return (!errorCondition) || connect(); return false; |
Map[] | getRow(String username, String password, String url, String driver, String query, String[] params) get Row Connection conn = null; PreparedStatement pstmt = null; ResultSet rs = null; try { conn = getConnection(username, password, url, driver); pstmt = conn.prepareStatement(query); if (params != null) { int offset = 1; ... |
int | getUserFace(String sUserName) returns default face for player int face = 1; if (checkConnection()) { try { userFaceQuery.setString(1, sUserName); ResultSet resultSet = userFaceQuery.executeQuery(); if (resultSet.next()) { face = resultSet.getInt(1); resultSet.close(); } catch (SQLException sqlE) { handleSQLException(sqlE); return face; |
String | getUserFromHost(String host) DOCUMENT ME! String nickname = null; if (checkConnection()) { try { hostQuery.setString(1, host); ResultSet resultSet = hostQuery.executeQuery(); if (resultSet.next()) { nickname = resultSet.getString(1); resultSet.close(); } catch (SQLException sqlE) { errorCondition = true; sqlE.printStackTrace(); throw sqlE; return nickname; |
ResultSet | query(String sql, Object... args) query, because need to manually close the resource, so not recommended for use it ResultSet result = null; Connection con = getconnnection(); PreparedStatement ps = null; try { ps = con.prepareStatement(sql); if (args != null) { for (int i = 0; i < args.length; i++) { ps.setObject((i + 1), args[i]); ... |
List | queryForList(String sql, Object... args) Query a single record List<Map<String, Object>> result = new ArrayList<Map<String, Object>>(); Connection con = null; ResultSet rs = null; PreparedStatement ps = null; try { con = getconnnection(); ps = con.prepareStatement(sql); if (args != null) { ... |