The concept used for executing a static SQL statement and obtaining
the results produced by it.
Only one JDBCResultSet concept per JDBCStatement concept can be open
at any point in time. Therefore, if the reading of one JDBCResultSet
concept is interleaved with the reading of another, each must have been
generated by different JDBCStatement objects. All statement execute methods
implicitly close a statment's current JDBCResultSet concept if an open one exists.
Establish the database connection.
$param typeof Map
$param.add("className", "org.postgresql.Driver")
$param.add("url", "jdbc:postgresql:testdb")
$param.add("user", "root")
$param.add("passwd", "")
$con = JDBCClient.getConnection( $param )
Create the JDBCStatement for sending SQL statements to the database.
$stmt = $con.createStatement
Execute a batch commands
#add SQL commands to current batch commands
$stmt.addBatch("SQL command(1)")
..........
..........
$stmt.addBatch("SQL command(n)")
#submit a batch commands to the database for execution
$stmt.executeBatch
#make current batch empty
$stmt.clearBatch
Execute SQL statements in singe and multiple results
#Executes an SQL statement that returns a single JDBCResultSet concept.
$rs = $stmt.executeQuery( "SQL command" )
#Executes an SQL statement that may return multiple results.
$stmt.execute("SQL command")
while $stmt.getMoreResults do [
$rs = $stmt.getResultSet]
Methods inherited from: Concept
cloneConcept, extendsConcept, fromXML, getAllInheritedConcepts, getConceptAttribute, getConceptAttributeField, getConceptAttributeFields, getConceptAttributes, getConceptConstructors, getConceptElement, getConceptElementField, getConceptElementFields, getConceptElements, getConceptLabel, getConceptMethod, getConceptMethods, getConceptOperators, getConceptType, getErrorHandler, getInheritedConcepts, getResourceURI, hasConceptAttribute, hasConceptElement, hasConceptMethod, hasPath, isHidden, loadContent, setConceptLabel, setErrorHandler, setHidden, setShowEmpty, showEmpty, toTXT, toXML, setResourceURI |
|
Parameters: |
$name : | the new cursor name, which must be unique within a connection |
|
Exceptions: |
SQLException :
(Error) | if a database access error occurs. |
Defines the SQL cursor name that will be used by subsequent JDBCStatement
concept execute methods. This name can then be used in SQL positioned
update/delete statements to identify the current row in the JDBCResultSet
concept generated by this statement.
If the database doesn't support positioned update/delete, then this method isn't working.
Note:
By definition, positioned update/delete execution must be done by a
different JDBCStatement concept than the one which generated the JDBCResultSet
concept being used for positioning.
Also, cursor names must be unique within a connection.
$param typeof Map
$param.add("className", "org.postgresql.Driver")
$param.add("url", "jdbc:postgresql:testdb")
$param.add("user", "root")
$param.add("passwd", "")
$con = JDBCClient.getConnection( $param )
$stmt = $con.createStatement
$stmt.setCursorName("SQLName")
$rs = $stmt.executeQuery("SELECT * FROM booleantb")
print $rs.getCursorName
$rs.close
$stmt.close
$con.close
-- the result is --
SQLName
Parameters: |
$sql : | typically this is a static SQL INSERT or UPDATE statement. |
|
Exceptions: |
SQLException :
(Error) | if a database access error occurs, or the driver does not support batch statements. |
Adds an SQL command to the current batch of commmands for this
JDBCStatement concept. This method is optional.
$param typeof Map
$param.add("className", "org.postgresql.Driver")
$param.add("url", "jdbc:postgresql:testdb")
$param.add("user", "root")
$param.add("passwd", "")
$con = JDBCClient.getConnection( $param )
$stmt = $con.createStatement
$stmt.addBatch("INSERT INTO booleantb VALUES(true)")
$stmt.addBatch("INSERT INTO booleantb VALUES(false)")
print $stmt.executeBatch@length + " rows inserted."
$stmt.clearBatch
$stmt.close
$con.close
-- the result is --
2 rows inserted.
Exceptions: |
SQLException :
(Error) | if a database access error occurs. |
Cancels this JDBCStatement concept if both the DBMS and driver support
aborting an SQL statement. This method can be used by a thread to cancel
a statement that is being executed by another thread.
Exceptions: |
SQLException :
(Error) | if a database access error occurs, or the driver does not support batch statements. |
Makes the set of commands in the current batch empty. This method is optional.
$param typeof Map
$param.add("className", "org.postgresql.Driver")
$param.add("url", "jdbc:postgresql:testdb")
$param.add("user", "root")
$param.add("passwd", "")
$con = JDBCClient.getConnection( $param )
$stmt = $con.createStatement
$stmt.addBatch("INSERT INTO booleantb VALUES(true)")
$stmt.addBatch("INSERT INTO booleantb VALUES(false)")
print $stmt.executeBatch@length + " rows inserted."
$stmt.clearBatch
$stmt.close
$con.close
-- the result is --
2 rows inserted.
Exceptions: |
SQLException :
(Error) | if a database access error occurs. |
Releases this JDBCStatement concept's database and JDBC resources
immediately instead of waiting for this to happen when it is
automatically closed. It is generally good practice to release resources
as soon as you are finished with them.
$param typeof Map
$param.add("className", "org.postgresql.Driver")
$param.add("url", "jdbc:postgresql:testdb")
$param.add("user", "root")
$param.add("passwd", "")
$con = JDBCClient.getConnection( $param )
$stmt = $con.createStatement
#................
$stmt.close
$con.close
-- the result is --
Exceptions: |
SQLException :
(Error) | if a database access error occurs. |
Executes an SQL statement that may return multiple results.
Under some (uncommon) situations a single SQL statement may return
multiple result sets and/or update counts.
Normally you can ignore this unless you are (1) executing a stored procedure
that you know may return multiple results or (2) you are dynamically
executing an unknown SQL string.
The methods execute, getMoreResults, getResultSet, and getUpdateCount let
you navigate through multiple results.
The execute method executes an SQL statement and indicates the form of the first result.
You can then use the methods getResultSet or getUpdateCount to retrieve the result,
and getMoreResults to move to any subsequent result(s).
$param typeof Map
$param.add("className", "org.postgresql.Driver")
$param.add("url", "jdbc:postgresql:testdb")
$param.add("user", "root")
$param.add("passwd", "")
$con = JDBCClient.getConnection( $param )
$stmt = $con.createStatement
print "Is INSERT method : " + ( $stmt.execute("INSERT INTO booleantb VALUES(true)") == false )
$stmt.close
$con.close
-- the result is --
Is INSERT method: true
Exceptions: |
SQLException :
(Error) |
- if a database access error occurs or the driver does not support batch statements.
- if one of the commands sent to the database fails to execute properly or attempts
to return a result set.
|
Submits a batch of commands to the database for execution and
if all commands execute successfully, returns a series of update counts.
The Integer elements of the series that is returned are ordered to
correspond to the commands in the batch, which are ordered according to
the order in which they were added to the batch.
The elements in the series returned by the method executeBatch
may be one of the following:
- A number greater than or equal to zero
- indicates that the command was processed successfully and
is an update count giving the number of rows in the database
that were affected by the command's execution- A value of -2
- indicates that the command was processed successfully
but that the number of rows affected is unknown
If one of the commands in a batch update fails to execute properly,
this method throws a BatchUpdateException, and the JDBC driver will
try to process the remaining commands in the batch. - A value of -3
- indicates that the command failed to execute successfully and
occurs only if a driver continues to process commands after a
command fails.
$param typeof Map
$param.add("className", "org.postgresql.Driver")
$param.add("url", "jdbc:postgresql:testdb")
$param.add("user", "root")
$param.add("passwd", "")
$con = JDBCClient.getConnection( $param )
$stmt = $con.createStatement
$stmt.addBatch("INSERT INTO booleantb VALUES(true)")
$stmt.addBatch("INSERT INTO booleantb VALUES(false)")
print $stmt.executeBatch@length + " rows inserted."
$stmt.clearBatch
$stmt.close
$con.close
-- the result is --
2 rows inserted.
Parameters: |
$sql : | typically this is a static SQL SELECT statement. |
|
Exceptions: |
SQLException :
(Error) | if a database access error occurs. |
Executes an SQL statement that returns a single JDBCResultSet concept.
$param typeof Map
$param.add("className", "org.postgresql.Driver")
$param.add("url", "jdbc:postgresql:testdb")
$param.add("user", "root")
$param.add("passwd", "")
$con = JDBCClient.getConnection( $param )
$stmt = $con.createStatement
$rs = $stmt.executeQuery("SELECT * FROM booleantb")
print $rs.getConceptType
$rs.close
$stmt.close
$con.close
-- the result is --
JDBCResultSet
Parameters: |
$sql : |
an SQL INSERT, UPDATE or DELETE statement or an SQL statement
that returns nothing. |
|
Exceptions: |
SQLException :
(Error) | if a database access error occurs. |
Executes an SQL INSERT, UPDATE or DELETE statement. In addition, SQL statements
that return nothing, such as SQL DDL statements, can be executed.
$param typeof Map
$param.add("className", "org.postgresql.Driver")
$param.add("url", "jdbc:postgresql:testdb")
$param.add("user", "root")
$param.add("passwd", "")
$con = JDBCClient.getConnection( $param )
$stmt = $con.createStatement
print "New record inserted: " + ( $stmt.executeUpdate("INSERT INTO booleantb VALUES(false)") == 1 )
print $rs.getConceptType
$rs.close
$stmt.close
$con.close
-- the result is --
New record inserted: true
Exceptions: |
SQLException :
(Error) | if a database access error occurs. |
Returns the JDBCConnection concept that produced this JDBCStatement concept.
$param typeof Map
$param.add("className", "org.postgresql.Driver")
$param.add("url", "jdbc:postgresql:testdb")
$param.add("user", "root")
$param.add("passwd", "")
$con = JDBCClient.getConnection( $param )
$stmt = $con.createStatement
print $stmt.getConnection.getConceptType
$stmt.close
$con.close
-- the result is --
JDBCConnection
Exceptions: |
SQLException :
(Error) | if a database access error occurs. |
Retrieves the direction for fetching rows from database tables that
is the default for result sets generated from this JDBCStatement concept.
If this JDBCStatement concept has not set a fetch direction by calling
the method setFetchDirection, the return value is implementation-specific.
$param typeof Map
$param.add("className", "org.gjt.mm.mysql.Driver")
$param.add("url", "jdbc:mysql:/localhost/testdb")
$param.add("user", "root")
$param.add("passwd", "")
$con = JDBCClient.getConnection( $param )
$stmt = $con.createStatement
print "Direction : " + $stmt.getFetchDirection
$stmt.close
$con.close
-- the result is --
Direction : UNKNOWN
Exceptions: |
SQLException :
(Error) | if a database access error occurs. |
Retrieves the number of result set rows that is the default fetch size
for result sets generated from this JDBCStatement concept.
If this JDBCStatement concept has not set a fetch size by calling the method
setFetchSize, the return value is implementation-specific.
$param typeof Map
$param.add("className", "org.gjt.mm.mysql.Driver")
$param.add("url", "jdbc:mysql:/localhost/testdb")
$param.add("user", "root")
$param.add("passwd", "")
$con = JDBCClient.getConnection( $param )
$stmt = $con.createStatement
print "Default fetch size is : " + $stmt.getFetchSize
$stmt.close
$con.close
-- the result is --
Default fetch size is : 0
Exceptions: |
SQLException :
(Error) | if a database access error occurs. |
Returns the maximum number of bytes allowed for any column value.
This limit is the maximum number of bytes that can be returned for
any column value. The limit applies only to BINARY, VARBINARY,
LONGVARBINARY, CHAR, VARCHAR, and LONGVARCHAR columns.
If the limit is exceeded, the excess data is silently discarded.
$param typeof Map
$param.add("className", "org.gjt.mm.mysql.Driver")
$param.add("url", "jdbc:mysql:/localhost/testdb")
$param.add("user", "root")
$param.add("passwd", "")
$con = JDBCClient.getConnection( $param )
$stmt = $con.createStatement
print "Max field size is : " + $stmt.getMaxFieldSize
$stmt.close
$con.close
-- the result is --
Max field size is : 65535
Exceptions: |
SQLException :
(Error) | if a database access error occurs. |
Retrieves the maximum number of rows that a JDBCResultSet concept can contain.
If the limit is exceeded, the excess rows are silently dropped.
$param typeof Map
$param.add("className", "org.gjt.mm.mysql.Driver")
$param.add("url", "jdbc:mysql:/localhost/testdb")
$param.add("user", "root")
$param.add("passwd", "")
$con = JDBCClient.getConnection( $param )
$stmt = $con.createStatement
print "Default maxRows is : " + $stmt.getMaxRows
$stmt.close
$con.close
-- the result is --
Default maxRows is : 0
Exceptions: |
SQLException :
(Error) | if a database access error occurs. |
Moves to a JDBCStatement concepts next result.
It returns true if this result is a JDBCResultSet concept.
This method also implicitly closes any current JDBCResultSet
concept obtained with the method getResultSet.
There are no more results when the following is true:
(not getMoreResults() and (getUpdateCount() == -1)
$param typeof Map
$param.add("className", "org.gjt.mm.mysql.Driver")
$param.add("url", "jdbc:mysql:/localhost/testdb")
$param.add("user", "root")
$param.add("passwd", "")
$con = JDBCClient.getConnection( $param )
$stmt = $con.createStatement
$stmt.setMaxRows(2)
$stmt.execute("SELECT * FROM chartb")
$rs = $stmt.getResultSet
$rs.setLast
print "RecordNr:" + $rs.getRow
print "Has more results:" + $stmt.getMoreResults
$stmt.close
$con.close
-- the result is --
RecordNr:2
Has more results:false
Exceptions: |
SQLException :
(Error) | if a database access error occurs. |
Returns the current result as a JDBCResultSet concept.
This method should be called only once per result.
$param typeof Map
$param.add("className", "org.gjt.mm.mysql.Driver")
$param.add("url", "jdbc:mysql:/localhost/testdb")
$param.add("user", "root")
$param.add("passwd", "")
$con = JDBCClient.getConnection( $param )
$stmt = $con.createStatement
$stmt.setMaxRows(2)
$stmt.execute("SELECT * FROM chartb")
$rs = $stmt.getResultSet
$rs.setLast
print "RecordNr:" + $rs.getRow
print "Has more results:" + $stmt.getMoreResults
$stmt.close
$con.close
-- the result is --
RecordNr:2
Has more results:false
Exceptions: |
SQLException :
(Error) | if a database access error occurs. |
Retrieves the result set concurrency for JDBCResultSet concepts
generated by this JDBCStatement concept.
Returns: either READ_ONLY
or UPDATABLE
$param typeof Map
$param.add("className", "org.gjt.mm.mysql.Driver")
$param.add("url", "jdbc:mysql:/localhost/testdb")
$param.add("user", "root")
$param.add("passwd", "")
$con = JDBCClient.getConnection( $param )
$stmt = $con.createStatement
print $stmt.getResultSetConcurrency
$stmt.close
$con.close
-- the result is --
UPDATABLE
Exceptions: |
SQLException :
(Error) | if a database access error occurs. |
Retrieves the result set type for JDBCResultSet concepts
generated by this JDBCStatement concept.
Returns: one of FORWARD
, INSENSITIVE
, or SENSITIVE
$param typeof Map
$param.add("className", "org.gjt.mm.mysql.Driver")
$param.add("url", "jdbc:mysql:/localhost/testdb")
$param.add("user", "root")
$param.add("passwd", "")
$con = JDBCClient.getConnection( $param )
$stmt = $con.createStatement
print $stmt.getResultSetType
$stmt.close
$con.close
-- the result is --
SENSITIVE
Exceptions: |
SQLException :
(Error) | if a database access error occurs. |
Returns the current result as an update count;
if the result is a JDBCResultSet concept or there are no more results,
-1 is returned. This method should be called only once per result.
$param typeof Map
$param.add("className", "org.postgresql.Driver")
$param.add("url", "jdbc:postgresql:testdb")
$param.add("user", "root")
$param.add("passwd", "")
$con = JDBCClient.getConnection( $param )
$stmt = $con.createStatement
$stmt.execute("INSERT INTO booleantb VALUES(false)")
print $stmt.getUpdateCount + " row(s) inserted."
$stmt.close
$con.close
-- the result is --
1 row(s) inserted.
Parameters: |
$direction : | the initial direction for processing rows. |
|
Exceptions: |
SQLException :
(Error) |
if a database access error occurs or the given direction is
not one of FORWARD
, REVERSE
, or UNKNOWN
|
Gives the driver a hint as to the direction in which the rows in
a result set will be processed. The hint applies only to result
sets created using this JDBCStatement concept.
The default value is FORWARD
.
Note that this method sets the default fetch direction for result
sets generated by this JDBCStatement concept.
Each result set has its own methods for getting and setting its
own fetch direction.
$param typeof Map
$param.add("className", "org.gjt.mm.mysql.Driver")
$param.add("url", "jdbc:mysql:/localhost/testdb")
$param.add("user", "root")
$param.add("passwd", "")
$con = JDBCClient.getConnection( $param )
$stmt = $con.createStatement
$stmt.setFetchDirection("FORWARD")
print "Direction : " + $stmt.getFetchDirection
$stmt.close
$con.close
-- the result is --
Direction : FORWARD
Parameters: |
$rows : | the number of rows to fetch. |
|
Exceptions: |
SQLException :
(Error) |
if a database access error occurs, or the condition
0 <= rows <= this.getMaxRows() is not satisfied.
|
Gives the JDBC driver a hint as to the number of rows that should be
fetched from the database when more rows are needed.
The number of rows specified affects only result sets created using
this statement. If the value specified is zero, then the hint is ignored.
The default value is zero.
$param typeof Map
$param.add("className", "org.gjt.mm.mysql.Driver")
$param.add("url", "jdbc:mysql:/localhost/testdb")
$param.add("user", "root")
$param.add("passwd", "")
$con = JDBCClient.getConnection( $param )
$stmt = $con.createStatement
$stmt.setFetchSize(3)
print "Fetch size is : " + $stmt.getFetchSize
$stmt.close
$con.close
-- the result is --
Fetch size is : 3
Parameters: |
$max : | the new max column size limit; zero means unlimited. |
|
Exceptions: |
SQLException :
(Error) | if a database access error occurs. |
Sets the limit for the maximum number of bytes in a column to the given number of bytes.
This is the maximum number of bytes that can be returned for any column value.
This limit applies only to BINARY, VARBINARY, LONGVARBINARY, CHAR, VARCHAR,
and LONGVARCHAR fields. If the limit is exceeded, the excess data is silently discarded.
For maximum portability, use values greater than 256.
$param typeof Map
$param.add("className", "org.gjt.mm.mysql.Driver")
$param.add("url", "jdbc:mysql:/localhost/testdb")
$param.add("user", "root")
$param.add("passwd", "")
$con = JDBCClient.getConnection( $param )
$stmt = $con.createStatement
$stmt.setMaxFieldSize(256)
print "Max field size is : " + $stmt.getMaxFieldSize
$stmt.close
$con.close
-- the result is --
Max field size is : 256
Parameters: |
$max : | the new max rows limit; zero means unlimited. |
|
Exceptions: |
SQLException :
(Error) | if a database access error occurs. |
Sets the limit for the maximum number of rows that any JDBCResultSet concept
can contain to the given number.
If the limit is exceeded, the excess rows are silently dropped.
$param typeof Map
$param.add("className", "org.gjt.mm.mysql.Driver")
$param.add("url", "jdbc:mysql:/localhost/testdb")
$param.add("user", "root")
$param.add("passwd", "")
$con = JDBCClient.getConnection( $param )
$stmt = $con.createStatement
$stmt.setMaxRows(3)
print "MaxRows is : " + $stmt.getMaxRows
$stmt.close
$con.close
-- the result is --
MaxRows is : 3