|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.spy.SpyObject
net.spy.db.SpyDB
public class SpyDB
SpyDB is an abstraction of both net.spy.pool and java.sql.
| Field Summary | |
|---|---|
protected static int |
INIT_FROM_CONFIG
Initialization type for SpyDB initialized from a config. |
protected static int |
INIT_FROM_CONN
Initialization type for SpyDB initialized from a Connection. |
| Constructor Summary | |
|---|---|
SpyDB(java.sql.Connection c)
Get a SpyDB object wrapping the given connection. |
|
SpyDB(SpyConfig c)
Create a SpyDB object based on the description found in the passed in SpyConfig object. |
|
| Method Summary | |
|---|---|
void |
close()
Free an established database connection - alias to freeDBConn() |
static java.lang.String |
dbquoteStr(java.lang.String in)
Make a string safe for usage in a SQL query, quoting apostrophies, etc... |
java.sql.ResultSet |
executeQuery(java.lang.String query)
Execute a query and return a resultset, will establish a database connection if necessary. |
int |
executeUpdate(java.lang.String query)
Execute a query that doesn't return a ResultSet, such as an update, delete, or insert. |
void |
freeDBConn()
Free an established database connection. |
protected SpyConfig |
getConfig()
Get the configuration from which this SpyDB was instatiated. |
java.sql.Connection |
getConn()
Get a connection out of the pool. |
int |
getInitType()
Get the type of initialization that created this object. |
protected ConnectionSource |
getSource()
Get the source of connections. |
protected void |
init()
Initialize SpyDB. |
boolean |
isClosed()
Has close() been called? |
java.sql.CallableStatement |
prepareCall(java.lang.String query)
Prepare a callable statement. |
java.sql.PreparedStatement |
prepareStatement(java.lang.String query)
Prepare a statement. |
| Methods inherited from class net.spy.SpyObject |
|---|
getLogger |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final int INIT_FROM_CONFIG
protected static final int INIT_FROM_CONN
| Constructor Detail |
|---|
public SpyDB(SpyConfig c)
The configuration may vary greatly depending on the connector. The
only configuration option for SpyDB itself is
dbConnectionSource which specifies the name of the class that
implements ConnectionSource that will be providing
connections for this SpyDB instance. The default is
net.spy.db.ObjectPoolConnectionSource.
You will also need to provide any additional parameters that are
required by the ConnectionSource in this config.
c - SpyConfig object describing how to connect.public SpyDB(java.sql.Connection c)
c - the connection to wrap.| Method Detail |
|---|
public int getInitType()
public java.sql.ResultSet executeQuery(java.lang.String query)
throws java.sql.SQLException
query - SQL query to execute.
java.sql.SQLException - an exception is thrown if the connection fails,
or the SQL query fails.
public int executeUpdate(java.lang.String query)
throws java.sql.SQLException
query - SQL query to execute.
java.sql.SQLException - an exception is thrown if the connection fails,
or the SQL query fails.
public java.sql.PreparedStatement prepareStatement(java.lang.String query)
throws java.sql.SQLException
query - SQL query to prepare.
java.sql.SQLException - thrown if something bad happens.
public java.sql.CallableStatement prepareCall(java.lang.String query)
throws java.sql.SQLException
query - SQL query to prepare for call.
java.sql.SQLException - thrown if something bad happens.
public java.sql.Connection getConn()
throws java.sql.SQLException
java.sql.SQLException - An exception may be thrown if a database
connection cannot be obtained.public void freeDBConn()
public void close()
protected void init()
public static java.lang.String dbquoteStr(java.lang.String in)
in - the string that needs to be quoted
public boolean isClosed()
protected ConnectionSource getSource()
protected SpyConfig getConfig()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||