ru.tehkode.permissions.backends.sql
Class SQLConnection

java.lang.Object
  extended by ru.tehkode.permissions.backends.sql.SQLConnection

public class SQLConnection
extends Object

Author:
code

Field Summary
protected  Map<String,String> aliases
           
protected  Connection db
           
protected  String dbDriver
           
protected  String password
           
protected static Pattern placeholderPattern
           
protected  String uri
           
protected  String user
           
 
Constructor Summary
SQLConnection(String uri, String user, String password, String dbDriver)
           
 
Method Summary
protected  void bindParams(PreparedStatement stmt, Object[] params)
           
protected  void checkConnection()
           
protected  void connect()
           
protected  void finalize()
           
 String getAlias(String tableName)
           
protected static String getDriverClass(String alias)
           
 void insert(String table, String[] fields, List<Object[]> rows)
           
 boolean isFieldExists(String tableName, String fieldName)
           
 boolean isTableExist(String tableName)
           
protected  String prepareQuery(String sql)
           
 ResultSet selectQuery(String sql, Object... params)
           
 Object selectQueryOne(String sql, Object fallback, Object... params)
           
 void setAlias(String tableName, String alias)
           
 void updateQuery(String sql, Object... params)
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

placeholderPattern

protected static Pattern placeholderPattern

db

protected Connection db

uri

protected String uri

user

protected String user

password

protected String password

dbDriver

protected String dbDriver

aliases

protected Map<String,String> aliases
Constructor Detail

SQLConnection

public SQLConnection(String uri,
                     String user,
                     String password,
                     String dbDriver)
Method Detail

setAlias

public void setAlias(String tableName,
                     String alias)

getAlias

public String getAlias(String tableName)

selectQuery

public ResultSet selectQuery(String sql,
                             Object... params)
                      throws SQLException
Throws:
SQLException

selectQueryOne

public Object selectQueryOne(String sql,
                             Object fallback,
                             Object... params)

updateQuery

public void updateQuery(String sql,
                        Object... params)

insert

public void insert(String table,
                   String[] fields,
                   List<Object[]> rows)
            throws SQLException
Throws:
SQLException

isTableExist

public boolean isTableExist(String tableName)

isFieldExists

public boolean isFieldExists(String tableName,
                             String fieldName)

checkConnection

protected void checkConnection()
                        throws SQLException
Throws:
SQLException

connect

protected final void connect()
                      throws SQLException
Throws:
SQLException

getDriverClass

protected static String getDriverClass(String alias)

bindParams

protected void bindParams(PreparedStatement stmt,
                          Object[] params)
                   throws SQLException
Throws:
SQLException

prepareQuery

protected String prepareQuery(String sql)

finalize

protected void finalize()
                 throws Throwable
Overrides:
finalize in class Object
Throws:
Throwable


Copyright © 2011. All Rights Reserved.