|
MDi JLib 1.7.4 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.microdeveloper.data.SQLDataSet
public class SQLDataSet
The implementation of the SQLSet, a java.sql.ResultSet which is wrapped in a self contained object with connection information, sql basis, sql parameters, and meta information related to a ResultSet.
The functionality of the class allows the class to be treated much like a simple collection with update capability. Updates are not performed on the object itself but rather through DML statements in the SQL property.
The class provides methods for manipulating the results of the Sql in a convienient manner and provides the following capabilities:
The parameters for the SQL call are flexible in that they can be as generic as an array of Strings, set individually,
or passed in as a batch. Unlike the SQL driver construct for a statement or prepared statement, you do not
need to make a particularly named call to set a variable. For example:
JDBC norm:
Connection conn = DriverManager... PreparedStatment ps = conn.prepareStatement (sql); ps.setString(1, "My Value");
Connection conn = DriverManager... SQLDataSet ds = new SQLDataSet(conn, sql); ds.setParameter(1, java.sql.Types.VARCHAR, "My Value");
To iterate over a SQLDataSet simply use the traditional JDBC methods. For example:
while (ds.next()) { System.out.println("Column foo: " + ds.getString("foo")); ... }
One area of confusion can come from setting primitive types such as int. You can use setInt(int, int), but
because setParameter takes an Object as an argument and int must be passed in as an Java object such as Integer by using Integer.valueOf(int).
Almost all primary and extended jdbc types are supported but only a limited set are supported by the setParameter call. If you attempt to use
a type that is not supported, you will get an UnsupportedSQLType exception. The following types are supported by setParameter:
SQL type (Java type): DATE (Date), INTEGER (Integer), DOUBLE (Double), FLOAT (Float), NUMERIC (Double), TIMESTAMP (Timestamp), VARCHAR (String)
So, if you can use the native parameter call why use setParameter? SetParameter does more than just set the argument in one call, it also examines the contents you pass in and automatically adjusts the value to the appropriate setNull call when the value given is, in fact, null. Because of this, you need not test for null and then programmatically set the appropriate call and SQLType. Mearly make a call to setParameter passing in the value (null or not), and the method will setup the rest.
Note: Arguments are being deprecated and removed from this class in favor of using parameters in the traditional jdbc sense. When passing in arguments in batches, use ArrayList objects to represent the components. You must provide 3 lists: name list, type list, and value list. Each must have the same number of entries and corresponding positioning. Arguments may also be set as an array of Strings which is treated as VARCHAR object types for DML purposes. Finally, it is also possible to simply call setArg(String) for very simple calls where there is only one argument. The type is assumed to be VARCHAR, the value is the String given, and the position is the first (and only) parameter.
Arguments set manually, in batches or through a direct call to query or update, are synchronized with the parameters, however the inverse is not true. If you set the parameters directly through setParameter or setXYZ where XYZ is the type (e.g., setInt), the argument list is not updated. The call to getParameterMetaData will always return the currently established parameter list.
Important: Always close the SQLDataSet when you are done using it. Failure to do so will result in a cursor leak which, if nested, could cause the database to run out of memory of throw internal errors. Closing the connection alone does not always free up cursors, and combined with certain drivers, will not cleanup cursors when used with Connection pooling even if the resultset is explicitly destroyed. Therefore always ensure that the ResultSet is released along with the PreparedStatement by using the close() method which will take care of releasing both immediately.
Constructor Summary | |
---|---|
SQLDataSet()
Initializes a new instance of SQLDataSet. |
|
SQLDataSet(Connection conn,
String sql)
Initializes a new instance of SQLDataSeta and establishes the connection and statement. |
Method Summary | |
---|---|
void |
addPropertyChangeListener(PropertyChangeListener listener)
Creates a property change listener |
void |
afterLast()
Moves the ResultSet cursor after the last record |
void |
beforeFirst()
Moves the ResultSet cursor before the 1st record |
void |
clearArgs()
Sets the current arguments and parameters to empty (null) |
void |
close()
Closes the ResultSet thereby freeing the cursors. |
boolean |
doCommit()
Performs a commit action within the database connection. |
boolean |
doRollback()
Performs a rollback action within the database connection. |
boolean |
doRollback(Savepoint sp)
Performs a rollback action within the database connection. |
ResultSet |
executeQuery()
Establishes and returns the ResultSet based on the SQL property value and the established parameters using the established Connection property. |
int |
executeUpdate()
Executes the SQL statement in this SQL property value, which must be an SQL INSERT, UPDATE or DELETE statement; or an SQL statement that returns nothing, such as a DDL statement. |
void |
finalize()
Cleans out the instance during garbage collection. |
void |
first()
Moves the cursor position to the first record in the ResultSet. |
ArrayList |
getArguments(String type)
Deprecated. as of 1.5 may be removed from future versions |
boolean |
getAutoCommit()
Returns the current state of automatic commit processing. |
boolean |
getAutoRollback()
Returns the current state of automatic rollback functionality. |
BigDecimal |
getBigDecimal(String columnName)
Gets a BigDecimal value from the current row based on the name of the column desired. |
Blob |
getBlob(String columnName)
Gets a Blob (Binary Large Object Block) object from the current row based on the name of the column desired. |
Clob |
getClob(String columnName)
Gets a Clob (Character Large Object Block) object from the current row based on the name of the column desired. |
int |
getColumnCount()
Gets the number of columns in the ResultSet |
String |
getColumnName(int i)
Gets the name of the column as indicated by the position of the column (i) within the ResultSet. |
String[] |
getColumnNames()
Gets the column names from the current ResultSet and returns them as a string array |
int |
getColumnPosition(String columnName)
Gets the position of a column in the resultset given the name of the column. |
String |
getColumnType(int i)
Gets the type of a particular column in the ResultSet by numeric position |
String |
getColumnType(String columnName)
Gets the database type of column in the selected drivers meta-data notation. |
boolean |
getCommitting()
Returns the current state of commit processing. |
Connection |
getConnection()
Gets the connection object for this instantiation. |
String |
getConnectionURL()
Gets the URL that describes or represents this jdbc connection. |
Connection |
getConnProperty()
Gets the current database connection object |
int |
getCurrentRow()
Deprecated. As of release 1.5, replaced by getRow() may be removed from future versions |
SQLSet |
getDataSetInterface()
Establishes the interface to a SQLDataSetInterface. |
Date |
getDate(String columnName)
Gets a Date value from the current row based on the name of the column desired using the default Calendar. |
Date |
getDate(String columnName,
Calendar cal)
Gets a Date value from the current row based on the name of the column desired using the Calendar specified. |
double |
getDouble(String columnName)
Gets a Double value from the current row based on the name of the column desired. |
float |
getFloat(String columnName)
Gets a Float value from the current row based on the name of the column desired. |
int |
getInt(String columnName)
Gets a Integer value from the current row based on the name of the column desired. |
Object |
getObject(int i)
Gets the column object specifed by integer position of the column for the current row. |
Object |
getObject(int row,
int column)
Gets the column object specifed by integer position of the row and column. |
Object |
getObject(int row,
String columnName)
Gets the column object specifed by integer position of the row and column. |
Object |
getObject(String columnName)
Gets the column object specifed by column name for the current row in the recordset. |
ParameterMetaData |
getParameterMetaData()
Retrieves the number, types and properties of this PreparedStatement object's parameters. |
ResultSet |
getResultSet()
Gets the current java.sql.ResultSet |
int |
getRow()
Gets in the position of the cursor within the ResultSet. |
int |
getRowCount()
Gets the current number of rows in the ResultSet |
int |
getSize()
Gets the number of rows in the current ResultSet |
String |
getSql()
Gets the SQL currently set for this instance |
String |
getSqlProperty()
Gets the currently established SQL property |
String |
getString(String columnName)
Gets a String value from the current row based on the name of the column desired. |
String |
getTableName(int i)
Gets the tablename from within the current resultset given the positional number of the table. |
Time |
getTime(String columnName)
Gets a Time value from the current row based on the name of the column desired using the default Calendar. |
Time |
getTime(String columnName,
Calendar cal)
Gets a Time value from the current row based on the name of the column desired using the Calendar specified. |
boolean |
hasData()
Gets the state of the ResultSet returning true if the ResultSet contains data, otherwise false. |
boolean |
isEmpty()
Determines of the ResultSet is empty or not |
void |
last()
Moves the cursor position to the last record in the ResultSet. |
boolean |
next()
Moves the record set pointer forward by one record. |
void |
nextRecord()
Deprecated. as of 1.7.1, replaced by next() may be removed from future versions |
boolean |
previous()
Method previous will move the record set pointer backward by one record. |
void |
previousRecord()
Deprecated. as of 1.7.1, replaced by previous() may be removed from future versions |
void |
query()
Deprecated. as of 1.5, replaced by executeQuery() may be removed from future versions |
void |
query(Connection conn,
String sql)
Deprecated. as of 1.5, replaced by executeQuery() may be removed from future versions |
void |
query(Connection conn,
String sql,
String[] args)
Deprecated. as of 1.5, replaced by executeQuery() may be removed from future versions |
void |
query(String sql)
Deprecated. as of 1.5, replaced by executeQuery() may be removed from future versions |
void |
query(String[] args)
Deprecated. as of 1.5, replaced by executeQuery() may be removed from future versions |
void |
query(String sql,
String[] args)
Deprecated. as of 1.5, replaced by executeQuery() may be removed from future versions |
void |
releaseSavepoint(Savepoint sp)
Releases a given savepoint. |
void |
removePropertyChangeListener(PropertyChangeListener listener)
Removes a set property |
void |
setArg(String arg)
Deprecated. As of release 1.5, replaced by setParameter(int,int,Object) |
void |
setArgs(String[] args)
Deprecated. As of release 1.5, replaced by setParameter(int,int,Object) |
void |
setArguments(ArrayList nameList,
ArrayList typeList,
ArrayList valueList)
Deprecated. As of release 1.5, replaced by setParameter(int,int,Object) |
void |
setArray(int parameterIndex,
Array x)
Sets the designated parameter to the given Java int value. |
void |
setAsciiStream(int parameterIndex,
InputStream x,
int length)
Sets the designated parameter to the given input stream, which will have the specified number of bytes. |
void |
setAutoCommit(boolean state)
Turns automatic comitting on or off. |
void |
setAutoRollback(boolean state)
Turns automatic rollback functionality on or off. |
void |
setBigDecimal(int parameterIndex,
BigDecimal x)
Sets the designated parameter to the given java.math.BigDecimal value. |
void |
setBinaryStream(int parameterIndex,
InputStream x,
int length)
Sets the designated parameter to the given input stream, which will have the specified number of bytes. |
void |
setBlob(int parameterIndex,
Blob x)
Sets the designated parameter to the given java.sql.Blob value. |
void |
setBoolean(int parameterIndex,
boolean x)
Sets the designated parameter to the given Java boolean value. |
void |
setByte(int parameterIndex,
byte x)
Sets the designated parameter to the given Java byte value. |
void |
setBytes(int parameterIndex,
byte[] x)
Sets the designated parameter to the given Java array of bytes value. |
void |
setCharacterStream(int parameterIndex,
Reader reader,
int length)
Sets the designated parameter to the given Reader object, which is the given number of characters long. |
void |
setClob(int parameterIndex,
Clob x)
Sets the designated parameter to the given java.sql.Clob value. |
void |
setCommitting(boolean state)
Turns commit processing on or off. |
void |
setConnection(Connection c)
Assigns the Connection c to this object to use for all operations |
void |
setConnProperty(Connection value)
Sets the current database connection property. |
void |
setCurrentRow(int i)
Sets the cursor position to an absolute row in the ResultSet |
void |
setData()
Deprecated. As of release 1.2, replaced by query() |
void |
setData(Connection conn,
String sql,
String[] args)
Deprecated. As of release 1.2, replaced by query(java.sql.Connection,String,String[]) |
void |
setData(String[] args)
Deprecated. As of release 1.2, replaced by query(String[]) |
void |
setData(String sql,
String[] args)
Deprecated. As of release 1.2, replaced by query(String,String[]) |
void |
setDate(int parameterIndex,
Date x)
Sets the designated parameter to the given java.sql.Date value. |
void |
setDate(int parameterIndex,
Date x,
Calendar cal)
Sets the designated parameter to the given java.sql.Date value, using the given Calendar object. |
void |
setDouble(int parameterIndex,
double x)
Sets the designated parameter to the given Java double value. |
void |
setFloat(int parameterIndex,
float x)
Sets the designated parameter to the given Java float value. |
void |
setInt(int parameterIndex,
int x)
Sets the designated parameter to the given Java int value. |
void |
setLong(int parameterIndex,
long x)
Sets the designated parameter to the given Java long value. |
void |
setNull(int parameterIndex,
int sqlType)
Sets the designated parameter to SQL NULL. |
void |
setObject(int parameterIndex,
Object x)
Sets the value of the designated parameter using the given object. |
void |
setParameter(int parameterIndex,
int sqlType,
Object x)
Sets a parameter for use in the subsequent query or update call by evaluating the type and object value passed in. |
void |
setRef(int parameterIndex,
Ref x)
Sets the designated parameter to the given REF( |
protected void |
setRowCount()
Sets the current row count property to the size of the current record set. |
Savepoint |
setSavePoint()
Sets an un-named savepoint in the current transaction. |
Savepoint |
setSavePoint(String s)
Sets an named savepoint in the current transaction. |
void |
setShort(int parameterIndex,
short x)
Sets the designated parameter to the given Java short value. |
void |
setSql(String sql)
Sets the SQL to use for performing queries to populate the ResultSet with. |
void |
setSqlProperty(String value)
Sets the current SQL code property used in a query |
void |
setString(int parameterIndex,
String x)
Sets the designated parameter to the given Java String value. |
void |
setTime(int parameterIndex,
Time x)
Sets the designated parameter to the given java.sql.Time value value. |
void |
setTime(int parameterIndex,
Time x,
Calendar cal)
Sets the designated parameter to the given java.sql.Time value, using the given Calendar object. |
void |
setTimestamp(int parameterIndex,
Timestamp x)
Sets the designated parameter to the given java.sql.Timestamp value. |
void |
setURL(int parameterIndex,
URL x)
Sets the designated parameter to the given java.net.URL value. |
Object[][] |
toObjectArray()
Converts the resultset to a two dimensional array of primitive type java.lang.Object (Object [][]). |
String[][] |
toStringArray()
Converts the resultset to a two dimensional array of type java.lang.String (String [][]). |
int |
update()
Deprecated. as of 1.5, replaced by executeUpdate() may be removed from future versions |
int |
update(Connection conn,
String sql)
Deprecated. as of 1.5, replaced by executeUpdate() may be removed from future versions |
int |
update(Connection conn,
String sql,
String[] args)
Deprecated. as of 1.5, replaced by executeUpdate() may be removed from future versions |
int |
update(String sql)
Deprecated. as of 1.5, replaced by executeUpdate() may be removed from future versions |
int |
update(String[] args)
Deprecated. as of 1.5, replaced by executeUpdate() may be removed from future versions |
int |
update(String sql,
String[] args)
Deprecated. as of 1.5, replaced by executeUpdate() may be removed from future versions |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SQLDataSet()
public SQLDataSet(Connection conn, String sql) throws SQLException
conn
- an open connection to the database URLsql
- an SQL statement that may contain one or more '?' IN parameter placeholders
SQLException
Method Detail |
---|
public SQLSet getDataSetInterface()
public void finalize() throws Throwable
finalize
in class Object
Throwable
public ArrayList getArguments(String type)
type
- One of the following (only first letter is relevant):
public Object[][] toObjectArray()
public String[][] toStringArray()
public Connection getConnection()
public String getConnectionURL() throws SQLException
SQLException
- if the resultset does not exist or a database error occurspublic int getColumnPosition(String columnName)
select x, y, z from dual
columnName
- the text name of the column to find. The column name is not case sensitive.
public String getTableName(int i)
For example, consider the following SQL:
select a.x, a.y, b.z from table_a, table_b where ...
i
- the position of the table within the SQL. 1 equals the first table, 2 the second and so on.
public String getString(String columnName) throws SQLException
columnName
- database column name, case insensitive
SQLException
- Throws a general exception if unable to fetch the columnpublic int getInt(String columnName) throws SQLException
columnName
- name of the column to fetch the value from the current record
SQLException
- thrown when unable to fetch the value, null values have no effectpublic Date getDate(String columnName) throws SQLException
columnName
- name of the column to fetch the value from the current record
SQLException
- thrown when unable to fetch the value, null values have no effectgetDate(String,java.util.Calendar)
public float getFloat(String columnName) throws SQLException
columnName
- name of the column to fetch the value from the current record
SQLException
- thrown when unable to fetch the value or the value is not of type Float, null values have no effectpublic BigDecimal getBigDecimal(String columnName) throws SQLException
columnName
- name of the column to fetch the value from the current record
SQLException
- thrown when unable to fetch the value or the value is not of type BigDecimal or cannot be coerced to Big Decimal, null values have no effectpublic Blob getBlob(String columnName) throws SQLException
columnName
- name of the column to fetch the value from the current record
SQLException
- thrown when unable to fetch the value or the value is not of type BLOB, null values have no effectpublic Date getDate(String columnName, Calendar cal) throws SQLException
columnName
- name of the column to fetch the value from the current recordcal
- a java.util.Calendar object
SQLException
- thrown when unable to fetch the value, null values have no effectgetDate(String)
public Time getTime(String columnName, Calendar cal) throws SQLException
columnName
- name of the column to fetch the value from the current recordcal
- a java.util.Calendar object
SQLException
- thrown when unable to fetch the value, null values have no effectgetTime(String)
,
getDate(String)
,
(String, Calendar)
public Time getTime(String columnName) throws SQLException
columnName
- name of the column to fetch the value from the current record
SQLException
- thrown when unable to fetch the value, null values have no effectgetTime(String)
,
getDate(String)
,
(String, Calendar)
public double getDouble(String columnName) throws SQLException
columnName
- name of the column to fetch the value from the current record
SQLException
- thrown when unable to fetch the value or the value is not of type Double, null values have no effectpublic Clob getClob(String columnName) throws SQLException
columnName
- name of the column to fetch the value from the current record
SQLException
- thrown when unable to fetch the value or the value is not of type CLOB, null values have no effectpublic String getColumnType(String columnName) throws SQLException
columnName
- name of the column to investigate
SQLException
- thrown if an error occurs, otherwise the value or nullpublic void beforeFirst() throws SQLException
SQLException
- thrown if a database access error occursafterLast()
,
first()
,
last()
,
next()
,
nextRecord()
,
previous()
,
previousRecord()
public void afterLast() throws SQLException
SQLException
- throws a SQL exception if an error occurs while
trying to reposition the result setbeforeFirst()
,
first()
,
last()
,
next()
,
nextRecord()
,
previous()
,
previousRecord()
public boolean next() throws SQLException
SQLException
- thrown if a database access error occursafterLast()
,
beforeFirst()
,
first()
,
last()
,
nextRecord()
,
previous()
,
previousRecord()
public void nextRecord() throws SQLException
next()
may be removed from future versions
SQLException
- thrown if no record is foundafterLast()
,
beforeFirst()
,
first()
,
last()
,
next()
,
previous()
,
previousRecord()
public boolean previous() throws SQLException
SQLException
- if a database access error occursafterLast()
,
beforeFirst()
,
first()
,
last()
,
next()
,
nextRecord()
,
previousRecord()
public void previousRecord() throws SQLException
previous()
may be removed from future versions
SQLException
- if a database access error occursafterLast()
,
beforeFirst()
,
first()
,
last()
,
next()
,
nextRecord()
,
previous()
public void first() throws SQLException
SQLException
- thrown if a database access error occursafterLast()
,
beforeFirst()
,
last()
,
next()
,
nextRecord()
,
previous()
,
previousRecord()
public void last() throws SQLException
SQLException
- thrown if a database access error occursafterLast()
,
beforeFirst()
,
first()
,
next()
,
nextRecord()
,
previous()
,
previousRecord()
public Object getObject(int row, int column) throws SQLException
getObject(1,1)would get the first column in the first row in the established record set. If the record set did not previously exist, an exception is thrown.
row
- the integer value of the record position (first record = 1)column
- the integer value of the column position (first column = 1)
SQLException
- thrown if an access or database error occursgetObject(String)
,
getObject(int,String)
,
getObject(int)
public Object getObject(int row, String columnName) throws SQLException
getObject(1,1)would get the first column in the first row in the established record set. If the record set did not previously exist, an exception is thrown.
row
- the integer value of the record position (first record = 1)columnName
- name of the column to retreive
SQLException
- thrown if an access or database error occursgetObject(int,int)
,
getObject(String)
,
getObject(int)
public Object getObject(String columnName) throws SQLException
columnName
- name of the column to fetch
SQLException
- thrown if an access or database error occursgetObject(int,int)
,
getObject(int,String)
,
getObject(int)
public Object getObject(int i) throws SQLException
i
- name of the column to fetch
SQLException
- thrown if an access or database error occursgetObject(int,int)
,
getObject(String)
,
getObject(int,String)
public ResultSet getResultSet()
public void setConnection(Connection c) throws SQLException
c
- valid opened java.sql.Connection object
SQLException
- thrown if the connection is not open or validpublic int getSize()
public String[] getColumnNames()
public int getColumnCount()
public String getColumnType(int i)
i
- position of the column in the result set
public boolean isEmpty()
public void setArg(String arg)
setParameter(int,int,Object)
arg
- single argument as a StringsetArguments(java.util.ArrayList,java.util.ArrayList,java.util.ArrayList)
,
getArguments(String)
,
clearArgs()
public void setArgs(String[] args)
setParameter(int,int,Object)
args
- list of Arguments in a string array, all arguments are
assumed to be of type String and anonymoussetArguments(java.util.ArrayList,java.util.ArrayList,java.util.ArrayList)
,
getArguments(String)
,
clearArgs()
public void setArguments(ArrayList nameList, ArrayList typeList, ArrayList valueList)
setParameter(int,int,Object)
nameList
- parameter name listtypeList
- parameter type listvalueList
- parameter value listsetArgs(String[])
,
getArguments(String)
,
clearArgs()
public void close()
public void clearArgs()
public void setSql(String sql)
sql
- an SQL statement that may contain one or more '?' IN parameter placeholdersgetSql()
public String getSql()
public boolean hasData()
isEmpty()
public void setCurrentRow(int i) throws SQLException
i
- row to point to
SQLException
- thrown if an access or database error occurspublic int getCurrentRow()
getRow()
may be removed from future versions
public int getRow()
This is the same as (deprecated) {link #getCurrentRow()}. Essentially this is exactly like calling ResultSet.getRow().
public int getRowCount()
public String getColumnName(int i)
i
- position of the column
public void setData() throws SQLException
query()
SQLException
- thrown if an access or database error occursquery()
,
query(String[])
,
query(String,String[])
,
query(java.sql.Connection,String,String[])
public void setData(String[] args) throws SQLException
query(String[])
args
- String array representing the corresponding argument values
SQLException
- thrown if an access or database error occursquery()
,
query(String[])
,
query(String,String[])
,
query(java.sql.Connection,String,String[])
public void setData(String sql, String[] args) throws SQLException
query(String,String[])
sql
- an SQL statement that may contain one or more '?' IN parameter placeholdersargs
- String array representing the corresponding argument values
SQLException
- thrown if an access or database error occursquery()
,
query(String[])
,
query(String,String[])
,
query(java.sql.Connection,String,String[])
public void setData(Connection conn, String sql, String[] args) throws SQLException
query(java.sql.Connection,String,String[])
conn
- Connection object representing an opened java.sql.Connectionsql
- an SQL statement that may contain one or more '?' IN parameter placeholdersargs
- String array representing the corresponding argument values
SQLException
- thrown if an access or database error occurspublic void query() throws SQLException
executeQuery()
may be removed from future versions
SQLException
- thrown if an access or database error occurspublic void query(String[] args) throws SQLException
executeQuery()
may be removed from future versions
args
- String array representing the corresponding argument values
SQLException
- thrown if an access or database error occurspublic void query(String sql, String[] args) throws SQLException
executeQuery()
may be removed from future versions
sql
- an SQL statement that may contain one or more '?' IN parameter placeholdersargs
- String array representing the corresponding argument values
SQLException
- thrown if an access or database error occurspublic void query(Connection conn, String sql, String[] args) throws SQLException
executeQuery()
may be removed from future versions
conn
- Connection object representing an opened java.sql.Connectionsql
- an SQL statement that may contain one or more '?' IN parameter placeholdersargs
- String array representing the corresponding argument values
SQLException
- thrown if an access or database error occurspublic void query(String sql) throws SQLException
executeQuery()
may be removed from future versions
sql
- an SQL statement that may contain one or more '?' IN parameter placeholders
SQLException
- thrown if an access or database error occurspublic void query(Connection conn, String sql) throws SQLException
executeQuery()
may be removed from future versions
conn
- Connection object representing an opened java.sql.Connectionsql
- an SQL statement that may contain one or more '?' IN parameter placeholders
SQLException
- thrown if an access or database error occurspublic ResultSet executeQuery() throws SQLException
SQLException
- if a database access error occurs or the SQL statement does not return a ResultSet objectpublic int executeUpdate() throws SQLException
SQLException
- if a database access error occurs or the SQL statement does not return a ResultSet objectpublic int update() throws SQLException
executeUpdate()
may be removed from future versions
SQLException
- thrown if an access or database error occurspublic int update(String[] args) throws SQLException
executeUpdate()
may be removed from future versions
args
- String array representing the corresponding argument values or null
SQLException
- thrown if an access or database error occurspublic int update(String sql) throws SQLException
executeUpdate()
may be removed from future versions
sql
- String representing the SQL to use
SQLException
- thrown if an access or database error occurspublic int update(String sql, String[] args) throws SQLException
executeUpdate()
may be removed from future versions
sql
- String representing the SQL to useargs
- String array representing the corresponding argument values
SQLException
- thrown if an access or database error occursquery()
,
query(String[])
,
query(String,String[])
,
query(java.sql.Connection,String,String[])
,
setConnProperty(java.sql.Connection)
,
setConnection(java.sql.Connection)
,
setSqlProperty(String)
,
setSql(String)
,
setArguments(java.util.ArrayList,java.util.ArrayList,java.util.ArrayList)
,
setArgs(String[])
public int update(Connection conn, String sql) throws SQLException
executeUpdate()
may be removed from future versions
conn
- Connection object representing an opened java.sql.Connectionsql
- String representing the SQL to use
SQLException
- thrown if an access or database error occurspublic int update(Connection conn, String sql, String[] args) throws SQLException
executeUpdate()
may be removed from future versions
conn
- Connection object representing an opened java.sql.Connectionsql
- String representing the SQL to useargs
- String array representing the corresponding argument values
SQLException
- thrown if an access or database error occurspublic String getSqlProperty()
public void setSqlProperty(String value)
value
- valid SQL codepublic void setParameter(int parameterIndex, int sqlType, Object x) throws SQLException
parameterIndex
- the first parameter is 1, the second is 2, ...sqlType
- the java.sql.Type of the parameter, target column, etc.x
- the parameter value
SQLException
- if a database access error occurspublic final ParameterMetaData getParameterMetaData() throws SQLException
SQLException
- if a database access error occurspublic Connection getConnProperty()
protected void setRowCount()
public void setConnProperty(Connection value) throws SQLException
value
- java.sql.Connection object
SQLException
public void addPropertyChangeListener(PropertyChangeListener listener)
listener
- PropertyChangeListener objectpublic void removePropertyChangeListener(PropertyChangeListener listener)
listener
- PropertyChangeListener objectpublic void setArray(int parameterIndex, Array x) throws SQLException
parameterIndex
- the first parameter is 1, the second is 2, ...x
- the parameter value
SQLException
- if a database access error occurspublic void setAsciiStream(int parameterIndex, InputStream x, int length) throws SQLException
parameterIndex
- the first parameter is 1, the second is 2, ...x
- the Java input stream that contains the ASCII parameter valuelength
- the number of bytes in the stream
SQLException
- if a database access error occurspublic void setBigDecimal(int parameterIndex, BigDecimal x) throws SQLException
parameterIndex
- the first parameter is 1, the second is 2, ...x
- the parameter value
SQLException
- if a database access error occurspublic void setBinaryStream(int parameterIndex, InputStream x, int length) throws SQLException
parameterIndex
- the first parameter is 1, the second is 2, ...x
- the Java input stream that contains the ASCII parameter valuelength
- the number of bytes in the stream
SQLException
- if a database access error occurspublic void setBlob(int parameterIndex, Blob x) throws SQLException
parameterIndex
- the first parameter is 1, the second is 2, ...x
- the parameter value
SQLException
- if a database access error occurspublic void setClob(int parameterIndex, Clob x) throws SQLException
parameterIndex
- the first parameter is 1, the second is 2, ...x
- the parameter value
SQLException
- if a database access error occurspublic void setBoolean(int parameterIndex, boolean x) throws SQLException
parameterIndex
- the first parameter is 1, the second is 2, ...x
- the parameter value
SQLException
- if a database access error occurspublic void setByte(int parameterIndex, byte x) throws SQLException
parameterIndex
- the first parameter is 1, the second is 2, ...x
- the parameter value
SQLException
- if a database access error occurspublic void setBytes(int parameterIndex, byte[] x) throws SQLException
parameterIndex
- the first parameter is 1, the second is 2, ...x
- the parameter value
SQLException
- if a database access error occurspublic void setCharacterStream(int parameterIndex, Reader reader, int length) throws SQLException
parameterIndex
- the first parameter is 1, the second is 2, ...reader
- the java.io.Reader object that contains the Unicode datalength
- the number of characters in the stream
SQLException
- if a database access error occurspublic void setNull(int parameterIndex, int sqlType) throws SQLException
parameterIndex
- the first parameter is 1, the second is 2, ...sqlType
- the SQL type code defined in java.sql.Types
SQLException
- if a database access error occurspublic void setObject(int parameterIndex, Object x) throws SQLException
parameterIndex
- the first parameter is 1, the second is 2, ...x
- the object containing the input parameter value
SQLException
- if a database access error occurs or the type of the given object is ambiguouspublic void setRef(int parameterIndex, Ref x) throws SQLException
parameterIndex
- the first parameter is 1, the second is 2, ...x
- an SQL REF value
SQLException
- if a database access error occurspublic void setShort(int parameterIndex, short x) throws SQLException
parameterIndex
- the first parameter is 1, the second is 2, ...x
- the parameter value
SQLException
- if a database access error occurspublic void setTime(int parameterIndex, Time x) throws SQLException
parameterIndex
- the first parameter is 1, the second is 2, ...x
- the parameter value
SQLException
- if a database access error occurspublic void setTime(int parameterIndex, Time x, Calendar cal) throws SQLException
parameterIndex
- the first parameter is 1, the second is 2, ...x
- the parameter valuecal
- the Calendar object the driver will use to construct the time
SQLException
- if a database access error occurspublic void setURL(int parameterIndex, URL x) throws SQLException
parameterIndex
- the first parameter is 1, the second is 2, ...x
- the java.net.URL object to be set
SQLException
- if a database access error occurspublic void setDate(int parameterIndex, Date x) throws SQLException
parameterIndex
- the first parameter is 1, the second is 2, ...x
- the parameter value
SQLException
- if a database access error occurspublic void setDate(int parameterIndex, Date x, Calendar cal) throws SQLException
parameterIndex
- the first parameter is 1, the second is 2, ...x
- the parameter valuecal
- the Calendar object the driver will use to construct the time
SQLException
- if a database access error occurspublic void setInt(int parameterIndex, int x) throws SQLException
parameterIndex
- the first parameter is 1, the second is 2, ...x
- the parameter value
SQLException
- if a database access error occurspublic void setString(int parameterIndex, String x) throws SQLException
parameterIndex
- the first parameter is 1, the second is 2, ...x
- the parameter value
SQLException
- if a database access error occurspublic void setDouble(int parameterIndex, double x) throws SQLException
parameterIndex
- the first parameter is 1, the second is 2, ...x
- the parameter value
SQLException
- if a database access error occurspublic void setFloat(int parameterIndex, float x) throws SQLException
parameterIndex
- the first parameter is 1, the second is 2, ...x
- the parameter value
SQLException
- if a database access error occurspublic void setLong(int parameterIndex, long x) throws SQLException
parameterIndex
- the first parameter is 1, the second is 2, ...x
- the parameter value
SQLException
- if a database access error occurspublic void setTimestamp(int parameterIndex, Timestamp x) throws SQLException
parameterIndex
- the first parameter is 1, the second is 2, ...x
- the parameter value
SQLException
- if a database access error occurspublic void setAutoCommit(boolean state)
doCommit()
method. If using the later, automatic rollback can also be employed whereby the transactions can
be coded with a commit statement that can be globally invoked by turning commit processing on or off. Turning
off automatic commit processing does not turn off commit processing independently. However, turning on automatic
commit processing does implicitly turn on committing.
state
- set to ON
to enable or OFF
to disablesetCommitting(boolean)
,
doCommit()
,
doRollback(java.sql.Savepoint)
public void setCommitting(boolean state)
doCommit()
perform the commit as expected. When off,
calls to doCommit()
have no effect. If automatic rollback is also enabled, when committing is off, the transaction
is rolledback when a doCommit()
command is encountered. When automatic rollback is off and committing is off
no action is taken with the transaction set.
Closing the connection or dataset will invoke a commit regardless of the commit settings.
It is also possible to override these calls by manipulating the Connection object directly.
Turning off committing also disables automatic commit processing, therefore there is no need to call setAutoCommit(boolean)
followed
by this method. Simply calling setCommitting with false will turn off both. Conversely, turning on Committing
will not automatically turn on automatic commit processing.
state
- set to ON
to enable or OFF
to disablesetAutoCommit(boolean)
,
doCommit()
,
doRollback(java.sql.Savepoint)
public void setAutoRollback(boolean state)
doCommit()
action would normally be processed, if automatic rollback
is enabled, the transaction is rolled back instead of committed. If automatic rollback is enabled and committing is also
enabled, the transaction is committed. If automatic rollback is enabled and committing is not, the transaction is
rolled back when a doCommit()
is encountered.
state
- set to ON
to enable or OFF
to disabledoCommit()
,
doRollback(java.sql.Savepoint)
public boolean doCommit()
setAutoRollback(boolean)
,
setAutoCommit(boolean)
,
setCommitting(boolean)
public boolean doRollback(Savepoint sp)
setAutoRollback(boolean)
functionality and will invoke the rollback regardless of the automatic
rollback or automatic commit state. If autocommit is enabled (the default), then this has no effect.
sp
- savepoint to rollback to
setAutoRollback(boolean)
,
setSavePoint()
public boolean doRollback()
setAutoRollback(boolean)
functionality and will invoke the rollback regardless of the automatic
rollback or automatic commit state.
setAutoRollback(boolean)
public boolean getAutoCommit()
setAutoCommit(boolean)
public boolean getCommitting()
setAutoCommit(boolean)
public boolean getAutoRollback()
setAutoRollback(boolean)
public Savepoint setSavePoint()
setAutoCommit(boolean)
public Savepoint setSavePoint(String s)
s
- the name given to the save point
setAutoCommit(boolean)
public void releaseSavepoint(Savepoint sp)
sp
- the savepoint to release
|
MDi JLib 1.7.4 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |