com.rc.celeritas.db
Class DBHelper

java.lang.Object
  extended by com.rc.celeritas.db.DBHelper

public class DBHelper
extends java.lang.Object

Author:
rchoudhary

Constructor Summary
DBHelper()
           
 
Method Summary
static boolean addDs(java.lang.String datasource)
           
static boolean addDs(java.lang.String[] datasources)
           
static void closeConnection(java.sql.Connection conn)
           
static int execute(java.lang.String sql)
           
static java.util.HashMap<java.lang.String,java.lang.String> fetchRow(java.lang.String sql)
           
static java.util.HashMap<java.lang.String,java.lang.String> fetchRow(java.lang.String table, java.lang.String pk, java.lang.String pVal)
           
static java.util.HashMap<java.lang.String,java.lang.String> generateLU(java.lang.String sql)
          Generate Lookup SQL
static java.lang.String generatePValFromSequence(java.lang.String seq)
           
static java.util.ArrayList<java.lang.String> getColumnNames(java.lang.String table)
           
static java.util.ArrayList<Column> getColumns(java.lang.String table)
          Return metadata about the columns in a table
static java.util.ArrayList<Column> getColumnsFromSQL(java.lang.String sql)
          Return the names of the column for a sql statement
static java.sql.Connection getConnection()
           
static java.lang.String getDateFormat()
          Return the date format set globally for the project
static java.util.ArrayList getQueryResults(java.lang.String sql)
           
static java.util.HashMap getRowMap(java.lang.String sql)
          Return a single row from the sql with column name as key.
static boolean init()
           
static java.util.HashMap<java.lang.String,java.lang.String> insert(java.lang.String insertSQL, java.lang.String table, java.lang.String pk, java.lang.String pVal)
           
static java.util.HashMap<java.lang.String,java.lang.String> update(java.lang.String updateSQL, java.lang.String table, java.lang.String pk, java.lang.String pVal)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DBHelper

public DBHelper()
Method Detail

getDateFormat

public static java.lang.String getDateFormat()
Return the date format set globally for the project

Returns:

getRowMap

public static java.util.HashMap getRowMap(java.lang.String sql)
                                   throws CeleritasException
Return a single row from the sql with column name as key. If sql returns no row than the map is null.

Parameters:
sql -
Returns:
Throws:
CeleritasException

generateLU

public static java.util.HashMap<java.lang.String,java.lang.String> generateLU(java.lang.String sql)
Generate Lookup SQL

Parameters:
sql -
Returns:

generatePValFromSequence

public static java.lang.String generatePValFromSequence(java.lang.String seq)
Parameters:
seq -
Returns:

getQueryResults

public static java.util.ArrayList getQueryResults(java.lang.String sql)
                                           throws CeleritasException
Parameters:
sql -
Returns:
Throws:
CeleritasException

init

public static boolean init()
                    throws CeleritasException
Returns:
Throws:
CeleritasException

addDs

public static boolean addDs(java.lang.String datasource)
                     throws CeleritasException,
                            java.lang.ClassCastException
Parameters:
datasource -
Returns:
Throws:
CeleritasException
java.lang.ClassCastException

addDs

public static boolean addDs(java.lang.String[] datasources)
                     throws CeleritasException,
                            java.lang.ClassCastException
Parameters:
datasources -
Returns:
Throws:
CeleritasException
java.lang.ClassCastException

getConnection

public static java.sql.Connection getConnection()
                                         throws CeleritasException
Returns:
Throws:
CeleritasException

getColumnNames

public static java.util.ArrayList<java.lang.String> getColumnNames(java.lang.String table)
                                                            throws CeleritasException
Parameters:
table -
Returns:
Throws:
CeleritasException

getColumns

public static java.util.ArrayList<Column> getColumns(java.lang.String table)
                                              throws CeleritasException
Return metadata about the columns in a table

Parameters:
table -
Returns:
Throws:
CeleritasException

getColumnsFromSQL

public static java.util.ArrayList<Column> getColumnsFromSQL(java.lang.String sql)
                                                     throws CeleritasException
Return the names of the column for a sql statement

Parameters:
sql -
Returns:
Throws:
CeleritasException

closeConnection

public static void closeConnection(java.sql.Connection conn)
Parameters:
conn -

insert

public static java.util.HashMap<java.lang.String,java.lang.String> insert(java.lang.String insertSQL,
                                                                          java.lang.String table,
                                                                          java.lang.String pk,
                                                                          java.lang.String pVal)
                                                                   throws CeleritasException
Parameters:
insertSQL -
table -
pk -
pVal -
Returns:
Throws:
CeleritasException

execute

public static int execute(java.lang.String sql)
                   throws CeleritasException
Parameters:
sql -
Returns:
Throws:
CeleritasException

fetchRow

public static java.util.HashMap<java.lang.String,java.lang.String> fetchRow(java.lang.String table,
                                                                            java.lang.String pk,
                                                                            java.lang.String pVal)
                                                                     throws CeleritasException
Parameters:
table -
pk -
pVal -
Returns:
Throws:
CeleritasException

fetchRow

public static java.util.HashMap<java.lang.String,java.lang.String> fetchRow(java.lang.String sql)
                                                                     throws CeleritasException
Parameters:
sql -
Returns:
Throws:
CeleritasException

update

public static java.util.HashMap<java.lang.String,java.lang.String> update(java.lang.String updateSQL,
                                                                          java.lang.String table,
                                                                          java.lang.String pk,
                                                                          java.lang.String pVal)
                                                                   throws CeleritasException
Parameters:
updateSQL -
table -
pk -
pVal -
Returns:
Throws:
CeleritasException


Copyright © 2008-2009 Rahul Choudhary. All Rights Reserved.