Java Utililty Methods JDBC Reds Connection

List of utility methods to do JDBC Reds Connection

Description

The list of methods to do JDBC Reds Connection are organized into topic(s).

Method

voidcreateRedshiftTable(String redshiftURL, Properties loginProperties, String tableName, List fields)
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();
booleancheckConnection()
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;
booleancheckConnection()
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;
...
intgetUserFace(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;
StringgetUserFromHost(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;
ResultSetquery(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) {
...