|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.pfsw.db.util.SQLExecutor
public class SQLExecutor
Provides an easy to use interface to execute SQL statements against a database.
Constructor Summary | |
---|---|
SQLExecutor(javax.sql.DataSource aDataSource)
Initialize the new instance with default values. |
Method Summary | |
---|---|
boolean |
close()
Closes all open connections. |
boolean |
closeStatement(java.sql.Statement statement)
Closes the given statement. |
protected java.sql.Connection |
connection()
|
protected void |
connection(java.sql.Connection newValue)
|
int |
execute(java.lang.String sql)
Executes the given SQL command and returns the number of affected rows. |
boolean |
executeSQL(java.lang.String sql)
Executes the given SQL command and returns true if the execution was successful. |
int |
executeWriteStatement(java.sql.PreparedStatement statement)
Executes the given statement and returns the number of affected rows. |
protected java.sql.Connection |
getConnection()
|
protected javax.sql.DataSource |
getDataSource()
|
protected boolean |
isClosed()
|
protected java.sql.Connection |
newConnection()
|
java.sql.PreparedStatement |
prepareWriteStatement(java.lang.String sql)
Returns a PreparedStatement for the given SQL command. |
protected void |
setDataSource(javax.sql.DataSource newValue)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SQLExecutor(javax.sql.DataSource aDataSource)
aDataSource
- The datasource the executor should connect to (must not be null)Method Detail |
---|
public java.sql.PreparedStatement prepareWriteStatement(java.lang.String sql) throws java.sql.SQLException
sql
- A valid SQL statement with placeholders (?) (no SELECT allowed here!)
java.sql.SQLException
- Any problem that occurs during executionpublic int executeWriteStatement(java.sql.PreparedStatement statement) throws java.sql.SQLException
statement
- A valid statement, created before by this executor
java.sql.SQLException
- Any problem that occurs during executionpublic int execute(java.lang.String sql) throws java.sql.SQLException
sql
- A valid SQL statement (no SELECT allowed here!)
java.sql.SQLException
- Any problem that occurs during executionpublic boolean executeSQL(java.lang.String sql)
sql
- A valid SQL statement (no SELECT allowed here!)public boolean close()
public boolean closeStatement(java.sql.Statement statement)
protected java.sql.Connection getConnection() throws java.sql.SQLException
java.sql.SQLException
protected java.sql.Connection newConnection() throws java.sql.SQLException
java.sql.SQLException
protected boolean isClosed()
protected javax.sql.DataSource getDataSource()
protected void setDataSource(javax.sql.DataSource newValue)
protected java.sql.Connection connection()
protected void connection(java.sql.Connection newValue)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |