|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.codestudio.util.SQLUtil
A utility class that is capable of performing any sql operation. All results from queries are returned as Hashtable arrays, where each Hashtable represents one row (record) of data (key=column_name, value=data).
If the sql is an update, insert, or delete, then the Hashtable array contains only one slice, and the value of that first Hashtable contains a description of the number of rows affected.
Results are cached by query that refreshes itself perdiocially, at a configurable interval that defaults to five minutes.
If you wish to force the cache to refresh before this interval, you should
either update the cacheRefresh parameter in the poolman.props file or
invoke the executeSql(String sql, boolean usecache)
method with the second argument set to 'false'. If the second argument
is set to true or ommitted, the cache will be used. The cache updates are
handled internally by a separate thread of execution.
For specific usage examples, take a look at Sample.java
in the samples
directory of the distribution.
Field Summary | |
static int |
MAX_ATTEMPTS
|
java.lang.String |
propsfilename
|
Method Summary | |
java.util.Hashtable[] |
doJDBC(java.lang.String dbname,
java.lang.String sql,
boolean goNative)
This method is called by the cache thread in SQLCache. |
protected java.util.Hashtable[] |
doJDBC(java.lang.String dbname,
java.lang.String sql,
java.sql.Connection con)
Executes a statement and returns results in the form of a Hashtable array. |
protected java.util.Hashtable[] |
doJDBC(java.lang.String dbname,
java.lang.String sql,
java.sql.Connection con,
boolean goNative)
Executes a statement and returns results in the form of a Hashtable array. |
SQLResult |
execute(java.lang.String sql)
|
SQLResult |
execute(java.lang.String dbname,
java.lang.String sql)
|
java.util.Hashtable[] |
executeSql(java.lang.String sql)
Simply executes executeSql(sql, true). |
java.util.Hashtable[] |
executeSql(java.lang.String dbname,
java.lang.String sql)
Begins the actual database operation by preparing resources. |
java.util.Enumeration |
getAllPoolnames()
Get a Vector containing all the names of the database pools currently in use. |
static SQLUtil |
getInstance()
The default method used to retrieve an instance of SQLUtil, based on the properties file SQLManager.DEFAULT_PROPSFILE, which must be in your CLASSPATH. |
static SQLUtil |
getInstance(java.util.Properties p)
An alternative method to retrieve an instance of SQLUtil, using a Properties object. |
static SQLUtil |
getInstance(java.lang.String propsfilename)
An alternative method to retrieve an instance of SQLUtil, using a specified props file. |
JDBCPool |
getPool(java.lang.String dbname)
|
static void |
main(java.lang.String[] args)
|
protected SQLResult |
makeResult(java.util.Hashtable[] h)
Wraps an array of Hashtables into a more convenient data structure, called a SQLResult. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int MAX_ATTEMPTS
public java.lang.String propsfilename
Method Detail |
public static void main(java.lang.String[] args)
public static SQLUtil getInstance()
public static SQLUtil getInstance(java.lang.String propsfilename)
public static SQLUtil getInstance(java.util.Properties p)
public SQLResult execute(java.lang.String sql) throws java.sql.SQLException
public SQLResult execute(java.lang.String dbname, java.lang.String sql) throws java.sql.SQLException
public java.util.Hashtable[] executeSql(java.lang.String sql) throws java.sql.SQLException
protected SQLResult makeResult(java.util.Hashtable[] h) throws java.sql.SQLException
public java.util.Enumeration getAllPoolnames()
public JDBCPool getPool(java.lang.String dbname)
public java.util.Hashtable[] executeSql(java.lang.String dbname, java.lang.String sql) throws java.sql.SQLException
public java.util.Hashtable[] doJDBC(java.lang.String dbname, java.lang.String sql, boolean goNative) throws java.sql.SQLException
protected java.util.Hashtable[] doJDBC(java.lang.String dbname, java.lang.String sql, java.sql.Connection con) throws java.sql.SQLException
protected java.util.Hashtable[] doJDBC(java.lang.String dbname, java.lang.String sql, java.sql.Connection con, boolean goNative) throws java.sql.SQLException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |