Book Home Java Enterprise in a Nutshell Search this book

Chapter 18. The java.sql Package

The java.sql package contains the entire JDBC API that sends SQL (Structured Query Language) statements to relational databases and retrieves the results of executing those SQL statements. Figure 18-1 shows the class hierarchy of this package. The JDBC 1.0 API became part of the core Java API in Java 1.1. The JDBC 2.0 API supports a variety of new features and is part of the Java 2 platform.

The Driver interface represents a specific JDBC implementation for a particular database system. Connection represents a connection to a database. The Statement, PreparedStatement, and CallableStatement interfaces support the execution of various kinds of SQL statements. ResultSet is a set of results returned by the database in response to a SQL query. The ResultSetMetaData interface provides metadata about a result set, while DatabaseMetaData provides metadata about the database as a whole.

figure

Figure 18-1. The java.sql Package

ArrayJava 1.2
java.sql

Provides an interface to SQL ARRAY objects. Each getArray() method returns a standard Java array of objects of the type returned by getBaseType(). Two getArray() methods support a java.util.Map parameter that can customize the SQL-type-to-Java-object mapping. The contents of the array can also be returned as a ResultSet using the various getResultSet() methods.

public abstract interface Array {
// Public Instance Methods
public abstract Object getArray () throws SQLException;
public abstract Object getArray (java.util.Map map) throws SQLException;
public abstract Object getArray (long index, int count) throws SQLException;
public abstract Object getArray (long index, int count, java.util.Map map) throws SQLException;
public abstract int getBaseType () throws SQLException;
public abstract String getBaseTypeName () throws SQLException;
public abstract ResultSet getResultSet () throws SQLException;
public abstract ResultSet getResultSet (java.util.Map map) throws SQLException;
public abstract ResultSet getResultSet (long index, int count) throws SQLException;
public abstract ResultSet getResultSet (long index, int count, java.util.Map map) throws SQLException;
}

Passed To: PreparedStatement.setArray(), SQLOutput.writeArray(), javax.sql.RowSet.setArray()

Returned By: CallableStatement.getArray(), ResultSet.getArray(), SQLInput.readArray()

BatchUpdateExceptionJava 1.2
java.sqlserializable checked

This exception, which is a subclass of SQLException, is thrown when a batch update operation fails. The exception includes a method, getUpdateCounts(), that returns an array of int values, where the values correspond to the update counts for the successful update operations in the batch.

public class BatchUpdateException extends SQLException {
// Public Constructors
public BatchUpdateException ();
public BatchUpdateException (int[ ] updateCounts);
public BatchUpdateException (String reason, int[ ] updateCounts);
public BatchUpdateException (String reason, String SQLState, int[ ] updateCounts);
public BatchUpdateException (String reason, String SQLState, int vendorCode, int[ ] updateCounts);
// Public Instance Methods
public int[ ] getUpdateCounts (); default:null
}

Hierarchy: Object-->Throwable(Serializable)-->Exception-->SQLException-->BatchUpdateException

BlobJava 1.2
java.sql

The Blob interface encapsulates a SQL BLOB field. The interface actually contains a pointer to the BLOB within the database, rather than the complete (and potentially very large) object. Data can be retrieved via a java.io.InputStream returned by getInputStream() or as an array of bytes returned by getBytes(). The length() method returns the number of bytes in the BLOB. The position() methods scan the contents of the Blob for a particular content sequence, represented by either another Blob object or a byte array. (The position() methods do not provide the current read-index within the BLOB).

public abstract interface Blob {
// Public Instance Methods
public abstract java.io.InputStream getBinaryStream () throws SQLException;
public abstract byte[ ] getBytes (long pos, int length) throws SQLException;
public abstract long length () throws SQLException;
public abstract long position (byte[ ] pattern, long start) throws SQLException;
public abstract long position (Blob pattern, long start) throws SQLException;
}

Passed To: Blob.position(), PreparedStatement.setBlob(), SQLOutput.writeBlob(), javax.sql.RowSet.setBlob()

Returned By: CallableStatement.getBlob(), ResultSet.getBlob(), SQLInput.readBlob()

CallableStatementJava 1.1
java.sqlPJ1.1(opt)

The CallableStatement interface allows programs to access SQL stored procedures within the database. You create a CallableStatement with the prepareCall() method of Connection. Question-mark characters (?) are used as placeholders for input and output values in the syntax that calls stored procedures:

{? = call procedure_name[(?[,?...])]}
{call procedure_name[(?[,?...])]}

Parameters are numbered sequentially starting from 1. Input parameters are set with the same setXXX() methods as in a PreparedStatement. Output parameters must be registered using the registerOutParameter() methods, and may be retrieved after the statement executes using the getXXX() methods, which are identical to those in ResultSet. To execute a statement, you call execute(), which is inherited from PreparedStatement.

public abstract interface CallableStatement extends PreparedStatement {
// Public Instance Methods
1.2public abstract java.sql.Array getArray (int i) throws SQLException;
1.2public abstract java.math.BigDecimal getBigDecimal (int parameterIndex) throws SQLException;
1.2public abstract Blob getBlob (int i) throws SQLException;
public abstract boolean getBoolean (int parameterIndex) throws SQLException;
public abstract byte getByte (int parameterIndex) throws SQLException;
public abstract byte[ ] getBytes (int parameterIndex) throws SQLException;
1.2public abstract Clob getClob (int i) throws SQLException;
public abstract java.sql.Date getDate (int parameterIndex) throws SQLException;
1.2public abstract java.sql.Date getDate (int parameterIndex, java.util.Calendar cal) throws SQLException;
public abstract double getDouble (int parameterIndex) throws SQLException;
public abstract float getFloat (int parameterIndex) throws SQLException;
public abstract int getInt (int parameterIndex) throws SQLException;
public abstract long getLong (int parameterIndex) throws SQLException;
public abstract Object getObject (int parameterIndex) throws SQLException;
1.2public abstract Object getObject (int i, java.util.Map map) throws SQLException;
1.2public abstract Ref getRef (int i) throws SQLException;
public abstract short getShort (int parameterIndex) throws SQLException;
public abstract String getString (int parameterIndex) throws SQLException;
public abstract Time getTime (int parameterIndex) throws SQLException;
1.2public abstract Time getTime (int parameterIndex, java.util.Calendar cal) throws SQLException;
public abstract Timestamp getTimestamp (int parameterIndex) throws SQLException;
1.2public abstract Timestamp getTimestamp (int parameterIndex, java.util.Calendar cal) throws SQLException;
public abstract void registerOutParameter (int parameterIndex, int sqlType) throws SQLException;
1.2public abstract void registerOutParameter (int paramIndex, int sqlType, String typeName) throws SQLException;
public abstract void registerOutParameter (int parameterIndex, int sqlType, int scale) throws SQLException;
public abstract boolean wasNull () throws SQLException;
// Deprecated Public Methods
#public abstract java.math.BigDecimal getBigDecimal (int parameterIndex, int scale) throws SQLException;
}

Hierarchy: (CallableStatement(PreparedStatement(Statement)))

Returned By: java.sql.Connection.prepareCall()

ClobJava 1.2
java.sql

The Clob interface encapsulates a SQL CLOB field. The interface actually contains a pointer to the CLOB within the database, rather than the complete character string. Data is retrieved via getAsciiStream(), which returns an InputStream, or via getCharacterStream(), which returns a Reader. The getSubString() method returns a specific substring within the CLOB, while the position() methods search the CLOB for a pattern and return the index of the pattern's first appearance.

public abstract interface Clob {
// Public Instance Methods
public abstract java.io.InputStream getAsciiStream () throws SQLException;
public abstract Reader getCharacterStream () throws SQLException;
public abstract String getSubString (long pos, int length) throws SQLException;
public abstract long length () throws SQLException;
public abstract long position (Clob searchstr, long start) throws SQLException;
public abstract long position (String searchstr, long start) throws SQLException;
}

Passed To: Clob.position(), PreparedStatement.setClob(), SQLOutput.writeClob(), javax.sql.RowSet.setClob()

Returned By: CallableStatement.getClob(), ResultSet.getClob(), SQLInput.readClob()

ConnectionJava 1.1
java.sqlPJ1.1(opt)

The Connection interface represents an individual database connection. The object includes factory methods for Statement, PreparedStatement, and CallableStatement objects and a number of transaction control methods (setAutoCommit(), commit(), rollback(), getAutoCommit(), setTransactionIsolation(), and getTransactionIsolation()). Other methods provide information about the database. The most important of these is getMetaData(), which returns a DatabaseMetaData object. The getWarnings() method returns any warnings pending for this connection.

Connection objects are created with the static DriverManager.getConnection() method.

public abstract interface Connection {
// Public Constants
public static final int TRANSACTION_NONE ; =0
public static final int TRANSACTION_READ_COMMITTED ; =2
public static final int TRANSACTION_READ_UNCOMMITTED ; =1
public static final int TRANSACTION_REPEATABLE_READ ; =4
public static final int TRANSACTION_SERIALIZABLE ; =8
// Public Instance Methods
public abstract void clearWarnings () throws SQLException;
public abstract void close () throws SQLException;
public abstract void commit () throws SQLException;
public abstract Statement createStatement () throws SQLException;
1.2public abstract Statement createStatement (int resultSetType, int resultSetConcurrency) throws SQLException;
public abstract boolean getAutoCommit () throws SQLException;
public abstract String getCatalog () throws SQLException;
public abstract DatabaseMetaData getMetaData () throws SQLException;
public abstract int getTransactionIsolation () throws SQLException;
1.2public abstract java.util.Map getTypeMap () throws SQLException;
public abstract SQLWarning getWarnings () throws SQLException;
public abstract boolean isClosed () throws SQLException;
public abstract boolean isReadOnly () throws SQLException;
public abstract String nativeSQL (String sql) throws SQLException;
public abstract CallableStatement prepareCall (String sql) throws SQLException;
1.2public abstract CallableStatement prepareCall (String sql, int resultSetType, int resultSetConcurrency) throws SQLException;
public abstract PreparedStatement prepareStatement (String sql) throws SQLException;
1.2public abstract PreparedStatement prepareStatement (String sql, int resultSetType, int resultSetConcurrency) throws SQLException;
public abstract void rollback () throws SQLException;
public abstract void setAutoCommit (boolean autoCommit) throws SQLException;
public abstract void setCatalog (String catalog) throws SQLException;
public abstract void setReadOnly (boolean readOnly) throws SQLException;
public abstract void setTransactionIsolation (int level) throws SQLException;
1.2public abstract void setTypeMap (java.util.Map map) throws SQLException;
}

Returned By: DatabaseMetaData.getConnection(), Driver.connect(), DriverManager.getConnection(), Statement.getConnection(), javax.sql.DataSource.getConnection(), javax.sql.PooledConnection.getConnection(), javax.sql.RowSetInternal.getConnection()

DatabaseMetaDataJava 1.1
java.sqlPJ1.1(opt)

The getMetaData() method of the Connection interface returns a DatabaseMetaData object that encapsulates nonconnection-dependent information about the underlying database. A number of methods return ResultSet objects that should be treated like any other ResultSet.

DatabaseMetaData methods that accept String parameters with names ending in "Pattern" allow for simple wildcard searching. These methods treat the % character as matching any number of characters and the _ character as matching any single character. If these parameters are set to null, pattern matching is not performed.

public abstract interface DatabaseMetaData {
// Public Constants
public static final int bestRowNotPseudo ; =1
public static final int bestRowPseudo ; =2
public static final int bestRowSession ; =2
public static final int bestRowTemporary ; =0
public static final int bestRowTransaction ; =1
public static final int bestRowUnknown ; =0
public static final int columnNoNulls ; =0
public static final int columnNullable ; =1
public static final int columnNullableUnknown ; =2
public static final int importedKeyCascade ; =0
public static final int importedKeyInitiallyDeferred ; =5
public static final int importedKeyInitiallyImmediate ; =6
public static final int importedKeyNoAction ; =3
public static final int importedKeyNotDeferrable ; =7
public static final int importedKeyRestrict ; =1
public static final int importedKeySetDefault ; =4
public static final int importedKeySetNull ; =2
public static final int procedureColumnIn ; =1
public static final int procedureColumnInOut ; =2
public static final int procedureColumnOut ; =4
public static final int procedureColumnResult ; =3
public static final int procedureColumnReturn ; =5
public static final int procedureColumnUnknown ; =0
public static final int procedureNoNulls ; =0
public static final int procedureNoResult ; =1
public static final int procedureNullable ; =1
public static final int procedureNullableUnknown ; =2
public static final int procedureResultUnknown ; =0
public static final int procedureReturnsResult ; =2
public static final short tableIndexClustered ; =1
public static final short tableIndexHashed ; =2
public static final short tableIndexOther ; =3
public static final short tableIndexStatistic ; =0
public static final int typeNoNulls ; =0
public static final int typeNullable ; =1
public static final int typeNullableUnknown ; =2
public static final int typePredBasic ; =2
public static final int typePredChar ; =1
public static final int typePredNone ; =0
public static final int typeSearchable ; =3
public static final int versionColumnNotPseudo ; =1
public static final int versionColumnPseudo ; =2
public static final int versionColumnUnknown ; =0
// Public Instance Methods
public abstract boolean allProceduresAreCallable () throws SQLException;
public abstract boolean allTablesAreSelectable () throws SQLException;
public abstract boolean dataDefinitionCausesTransactionCommit () throws SQLException;
public abstract boolean dataDefinitionIgnoredInTransactions () throws SQLException;
1.2public abstract boolean deletesAreDetected (int type) throws SQLException;
public abstract boolean doesMaxRowSizeIncludeBlobs () throws SQLException;
public abstract ResultSet getBestRowIdentifier (String catalog, String schema, String table, int scope, boolean nullable) throws SQLException;
public abstract ResultSet getCatalogs () throws SQLException;
public abstract String getCatalogSeparator () throws SQLException;
public abstract String getCatalogTerm () throws SQLException;
public abstract ResultSet getColumnPrivileges (String catalog, String schema, String table, String columnNamePattern) throws SQLException;
public abstract ResultSet getColumns (String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) throws SQLException;
1.2public abstract java.sql.Connection getConnection () throws SQLException;
public abstract ResultSet getCrossReference (String primaryCatalog, String primarySchema, String primaryTable, String foreignCatalog, String foreignSchema, String foreignTable) throws SQLException;
public abstract String getDatabaseProductName () throws SQLException;
public abstract String getDatabaseProductVersion () throws SQLException;
public abstract int getDefaultTransactionIsolation () throws SQLException;
public abstract int getDriverMajorVersion ();
public abstract int getDriverMinorVersion ();
public abstract String getDriverName () throws SQLException;
public abstract String getDriverVersion () throws SQLException;
public abstract ResultSet getExportedKeys (String catalog, String schema, String table) throws SQLException;
public abstract String getExtraNameCharacters () throws SQLException;
public abstract String getIdentifierQuoteString () throws SQLException;
public abstract ResultSet getImportedKeys (String catalog, String schema, String table) throws SQLException;
public abstract ResultSet getIndexInfo (String catalog, String schema, String table, boolean unique, boolean approximate) throws SQLException;
public abstract int getMaxBinaryLiteralLength () throws SQLException;
public abstract int getMaxCatalogNameLength () throws SQLException;
public abstract int getMaxCharLiteralLength () throws SQLException;
public abstract int getMaxColumnNameLength () throws SQLException;
public abstract int getMaxColumnsInGroupBy () throws SQLException;
public abstract int getMaxColumnsInIndex () throws SQLException;
public abstract int getMaxColumnsInOrderBy () throws SQLException;
public abstract int getMaxColumnsInSelect () throws SQLException;
public abstract int getMaxColumnsInTable () throws SQLException;
public abstract int getMaxConnections () throws SQLException;
public abstract int getMaxCursorNameLength () throws SQLException;
public abstract int getMaxIndexLength () throws SQLException;
public abstract int getMaxProcedureNameLength () throws SQLException;
public abstract int getMaxRowSize () throws SQLException;
public abstract int getMaxSchemaNameLength () throws SQLException;
public abstract int getMaxStatementLength () throws SQLException;
public abstract int getMaxStatements () throws SQLException;
public abstract int getMaxTableNameLength () throws SQLException;
public abstract int getMaxTablesInSelect () throws SQLException;
public abstract int getMaxUserNameLength () throws SQLException;
public abstract String getNumericFunctions () throws SQLException;
public abstract ResultSet getPrimaryKeys (String catalog, String schema, String table) throws SQLException;
public abstract ResultSet getProcedureColumns (String catalog, String schemaPattern, String procedureNamePattern, String columnNamePattern) throws SQLException;
public abstract ResultSet getProcedures (String catalog, String schemaPattern, String procedureNamePattern) throws SQLException;
public abstract String getProcedureTerm () throws SQLException;
public abstract ResultSet getSchemas () throws SQLException;
public abstract String getSchemaTerm () throws SQLException;
public abstract String getSearchStringEscape () throws SQLException;
public abstract String getSQLKeywords () throws SQLException;
public abstract String getStringFunctions () throws SQLException;
public abstract String getSystemFunctions () throws SQLException;
public abstract ResultSet getTablePrivileges (String catalog, String schemaPattern, String tableNamePattern) throws SQLException;
public abstract ResultSet getTables (String catalog, String schemaPattern, String tableNamePattern, String[ ] types) throws SQLException;
public abstract ResultSet getTableTypes () throws SQLException;
public abstract String getTimeDateFunctions () throws SQLException;
public abstract ResultSet getTypeInfo () throws SQLException;
1.2public abstract ResultSet getUDTs (String catalog, String schemaPattern, String typeNamePattern, int[ ] types) throws SQLException;
public abstract String getURL () throws SQLException;
public abstract String getUserName () throws SQLException;
public abstract ResultSet getVersionColumns (String catalog, String schema, String table) throws SQLException;
1.2public abstract boolean insertsAreDetected (int type) throws SQLException;
public abstract boolean isCatalogAtStart () throws SQLException;
public abstract boolean isReadOnly () throws SQLException;
public abstract boolean nullPlusNonNullIsNull () throws SQLException;
public abstract boolean nullsAreSortedAtEnd () throws SQLException;
public abstract boolean nullsAreSortedAtStart () throws SQLException;
public abstract boolean nullsAreSortedHigh () throws SQLException;
public abstract boolean nullsAreSortedLow () throws SQLException;
1.2public abstract boolean othersDeletesAreVisible (int type) throws SQLException;
1.2public abstract boolean othersInsertsAreVisible (int type) throws SQLException;
1.2public abstract boolean othersUpdatesAreVisible (int type) throws SQLException;
1.2public abstract boolean ownDeletesAreVisible (int type) throws SQLException;
1.2public abstract boolean ownInsertsAreVisible (int type) throws SQLException;
1.2public abstract boolean ownUpdatesAreVisible (int type) throws SQLException;
public abstract boolean storesLowerCaseIdentifiers () throws SQLException;
public abstract boolean storesLowerCaseQuotedIdentifiers () throws SQLException;
public abstract boolean storesMixedCaseIdentifiers () throws SQLException;
public abstract boolean storesMixedCaseQuotedIdentifiers () throws SQLException;
public abstract boolean storesUpperCaseIdentifiers () throws SQLException;
public abstract boolean storesUpperCaseQuotedIdentifiers () throws SQLException;
public abstract boolean supportsAlterTableWithAddColumn () throws SQLException;
public abstract boolean supportsAlterTableWithDropColumn () throws SQLException;
public abstract boolean supportsANSI92EntryLevelSQL () throws SQLException;
public abstract boolean supportsANSI92FullSQL () throws SQLException;
public abstract boolean supportsANSI92IntermediateSQL () throws SQLException;
1.2public abstract boolean supportsBatchUpdates () throws SQLException;
public abstract boolean supportsCatalogsInDataManipulation () throws SQLException;
public abstract boolean supportsCatalogsInIndexDefinitions () throws SQLException;
public abstract boolean supportsCatalogsInPrivilegeDefinitions () throws SQLException;
public abstract boolean supportsCatalogsInProcedureCalls () throws SQLException;
public abstract boolean supportsCatalogsInTableDefinitions () throws SQLException;
public abstract boolean supportsColumnAliasing () throws SQLException;
public abstract boolean supportsConvert () throws SQLException;
public abstract boolean supportsConvert (int fromType, int toType) throws SQLException;
public abstract boolean supportsCoreSQLGrammar () throws SQLException;
public abstract boolean supportsCorrelatedSubqueries () throws SQLException;
public abstract boolean supportsDataDefinitionAndDataManipulationTransactions () throws SQLException;
public abstract boolean supportsDataManipulationTransactionsOnly () throws SQLException;
public abstract boolean supportsDifferentTableCorrelationNames () throws SQLException;
public abstract boolean supportsExpressionsInOrderBy () throws SQLException;
public abstract boolean supportsExtendedSQLGrammar () throws SQLException;
public abstract boolean supportsFullOuterJoins () throws SQLException;
public abstract boolean supportsGroupBy () throws SQLException;
public abstract boolean supportsGroupByBeyondSelect () throws SQLException;
public abstract boolean supportsGroupByUnrelated () throws SQLException;
public abstract boolean supportsIntegrityEnhancementFacility () throws SQLException;
public abstract boolean supportsLikeEscapeClause () throws SQLException;
public abstract boolean supportsLimitedOuterJoins () throws SQLException;
public abstract boolean supportsMinimumSQLGrammar () throws SQLException;
public abstract boolean supportsMixedCaseIdentifiers () throws SQLException;
public abstract boolean supportsMixedCaseQuotedIdentifiers () throws SQLException;
public abstract boolean supportsMultipleResultSets () throws SQLException;
public abstract boolean supportsMultipleTransactions () throws SQLException;
public abstract boolean supportsNonNullableColumns () throws SQLException;
public abstract boolean supportsOpenCursorsAcrossCommit () throws SQLException;
public abstract boolean supportsOpenCursorsAcrossRollback () throws SQLException;
public abstract boolean supportsOpenStatementsAcrossCommit () throws SQLException;
public abstract boolean supportsOpenStatementsAcrossRollback () throws SQLException;
public abstract boolean supportsOrderByUnrelated () throws SQLException;
public abstract boolean supportsOuterJoins () throws SQLException;
public abstract boolean supportsPositionedDelete () throws SQLException;
public abstract boolean supportsPositionedUpdate () throws SQLException;
1.2public abstract boolean supportsResultSetConcurrency (int type, int concurrency) throws SQLException;
1.2public abstract boolean supportsResultSetType (int type) throws SQLException;
public abstract boolean supportsSchemasInDataManipulation () throws SQLException;
public abstract boolean supportsSchemasInIndexDefinitions () throws SQLException;
public abstract boolean supportsSchemasInPrivilegeDefinitions () throws SQLException;
public abstract boolean supportsSchemasInProcedureCalls () throws SQLException;
public abstract boolean supportsSchemasInTableDefinitions () throws SQLException;
public abstract boolean supportsSelectForUpdate () throws SQLException;
public abstract boolean supportsStoredProcedures () throws SQLException;
public abstract boolean supportsSubqueriesInComparisons () throws SQLException;
public abstract boolean supportsSubqueriesInExists () throws SQLException;
public abstract boolean supportsSubqueriesInIns () throws SQLException;
public abstract boolean supportsSubqueriesInQuantifieds () throws SQLException;
public abstract boolean supportsTableCorrelationNames () throws SQLException;
public abstract boolean supportsTransactionIsolationLevel (int level) throws SQLException;
public abstract boolean supportsTransactions () throws SQLException;
public abstract boolean supportsUnion () throws SQLException;
public abstract boolean supportsUnionAll () throws SQLException;
1.2public abstract boolean updatesAreDetected (int type) throws SQLException;
public abstract boolean usesLocalFilePerTable () throws SQLException;
public abstract boolean usesLocalFiles () throws SQLException;
}

Returned By: java.sql.Connection.getMetaData()

DataTruncationJava 1.1
java.sqlserializable checked PJ1.1(opt)

This subclass of SQLWarning is a special warning used when JDBC unexpectedly truncates a data value. It is chained as a warning on read operations and thrown as an exception on write operations.

public class DataTruncation extends SQLWarning {
// Public Constructors
public DataTruncation (int index, boolean parameter, boolean read, int dataSize, int transferSize);
// Public Instance Methods
public int getDataSize ();
public int getIndex ();
public boolean getParameter ();
public boolean getRead ();
public int getTransferSize ();
}

Hierarchy: Object-->Throwable(Serializable)-->Exception-->SQLException-->SQLWarning-->DataTruncation

DateJava 1.1
java.sqlcloneable serializable comparable PJ1.1(opt)

A wrapper around the java.util.Date class that adjusts the time value (milliseconds since January 1, 1970 0:00:00 GMT) to conform to the SQL DATE specification. The DATE type only deals with the day, month, and year, so the hours, minutes, seconds, and milliseconds are set to 00:00:00.00 in the current time zone. The Date class also includes a static valueOf() method that decodes the JDBC Date escape syntax yyyy-mm-dd into a Date value.

public class Date extends java.util.Date {
// Public Constructors
public Date (long date);
#public Date (int year, int month, int day);
// Public Class Methods
public static java.sql.Date valueOf (String s);
// Public methods overriding Date
public void setTime (long date);
public String toString ();
// Deprecated Public Methods
#public int getHours (); Overrides:Date
#public int getMinutes (); Overrides:Date
#public int getSeconds (); Overrides:Date
#public void setHours (int i); Overrides:Date
#public void setMinutes (int i); Overrides:Date
#public void setSeconds (int i); Overrides:Date
}

Hierarchy: Object-->java.util.Date(Serializable,Cloneable,Comparable)-->java.sql.Date

Passed To: PreparedStatement.setDate(), ResultSet.updateDate(), SQLOutput.writeDate(), javax.sql.RowSet.setDate()

Returned By: CallableStatement.getDate(), java.sql.Date.valueOf(), ResultSet.getDate(), SQLInput.readDate()

DriverJava 1.1
java.sqlPJ1.1(opt)

Every JDBC driver must implement the Driver interface. Most programmers never need to deal with this interface, except when using the DriverManager.registerDriver() method, which is generally not recommended. The better way to register a driver is to load the driver by calling Class.forName() on the driver class, which automatically registers the driver as well.

public abstract interface Driver {
// Public Instance Methods
public abstract boolean acceptsURL (String url) throws SQLException;
public abstract java.sql.Connection connect (String url, java.util.Properties info) throws SQLException;
public abstract int getMajorVersion ();
public abstract int getMinorVersion ();
public abstract DriverPropertyInfo[ ] getPropertyInfo (String url, java.util.Properties info) throws SQLException;
public abstract boolean jdbcCompliant ();
}

Passed To: DriverManager.{deregisterDriver(), registerDriver()}

Returned By: DriverManager.getDriver()

DriverManagerJava 1.1
java.sqlPJ1.1(opt)

The DriverManager class is responsible for loading JDBC drivers and creating Connection objects. It starts by loading all the drivers specified in the jdbc.drivers system property. Individual drivers can also be loaded by calling Class.forName() with the driver class name.

Programs use the static DriverManager.getConnection() method to create individual database connections. The driver manager creates the Connection using the appropriate driver, based on the JDBC URL specified in the call to getConnection().

public class DriverManager {
// No Constructor
// Public Class Methods
public static void deregisterDriver (Driver driver) throws SQLException; synchronized
public static java.sql.Connection getConnection (String url) throws SQLException; synchronized
public static java.sql.Connection getConnection (String url, java.util.Properties info) throws SQLException; synchronized
public static java.sql.Connection getConnection (String url, String user, String password) throws SQLException; synchronized
public static Driver getDriver (String url) throws SQLException; synchronized
public static java.util.Enumeration getDrivers (); synchronized
public static int getLoginTimeout ();
1.2public static PrintWriter getLogWriter ();
public static void println (String message); synchronized
public static void registerDriver (Driver driver) throws SQLException; synchronized
public static void setLoginTimeout (int seconds);
1.2public static void setLogWriter (PrintWriter out); synchronized
// Deprecated Public Methods
#public static PrintStream getLogStream ();
#public static void setLogStream (PrintStream out); synchronized
}
DriverPropertyInfoJava 1.1
java.sqlPJ1.1(opt)

The DriverPropertyInfo class contains the properties required to create a new database connection using a particular driver. It is returned by the getDriverProperties() method of Driver. This class is useful only for programmers who need to interact directly with the driver in a dynamic manner.

public class DriverPropertyInfo {
// Public Constructors
public DriverPropertyInfo (String name, String value);
// Public Instance Fields
public String[ ] choices ;
public String description ;
public String name ;
public boolean required ;
public String value ;
}

Returned By: Driver.getPropertyInfo()

PreparedStatementJava 1.1
java.sqlPJ1.1(opt)

The PreparedStatement interface allows programs to precompile SQL statements for increased performance. You obtain a PreparedStatement object with the prepareStatement() method of Connection. Parameters in the statement are denoted by ? characters in the SQL string and indexed from 1 to n. Individual parameter values are set using the setXXX() methods, while the clearParameters() method clears all the parameters. Note that some JDBC drivers do not implement setObject() properly when dealing with null field types. Once all parameters have been set, the statement is executed using execute(), executeQuery(), or executeUpdate(). Unlike with the Statement object, the execution methods take no parameters.

public abstract interface PreparedStatement extends Statement {
// Public Instance Methods
1.2public abstract void addBatch () throws SQLException;
public abstract void clearParameters () throws SQLException;
public abstract boolean execute () throws SQLException;
public abstract ResultSet executeQuery () throws SQLException;
public abstract int executeUpdate () throws SQLException;
1.2public abstract ResultSetMetaData getMetaData () throws SQLException;
1.2public abstract void setArray (int i, java.sql.Array x) throws SQLException;
public abstract void setAsciiStream (int parameterIndex, java.io.InputStream x, int length) throws SQLException;
public abstract void setBigDecimal (int parameterIndex, java.math.BigDecimal x) throws SQLException;
public abstract void setBinaryStream (int parameterIndex, java.io.InputStream x, int length) throws SQLException;
1.2public abstract void setBlob (int i, Blob x) throws SQLException;
public abstract void setBoolean (int parameterIndex, boolean x) throws SQLException;
public abstract void setByte (int parameterIndex, byte x) throws SQLException;
public abstract void setBytes (int parameterIndex, byte[ ] x) throws SQLException;
1.2public abstract void setCharacterStream (int parameterIndex, Reader reader, int length) throws SQLException;
1.2public abstract void setClob (int i, Clob x) throws SQLException;
public abstract void setDate (int parameterIndex, java.sql.Date x) throws SQLException;
1.2public abstract void setDate (int parameterIndex, java.sql.Date x, java.util.Calendar cal) throws SQLException;
public abstract void setDouble (int parameterIndex, double x) throws SQLException;
public abstract void setFloat (int parameterIndex, float x) throws SQLException;
public abstract void setInt (int parameterIndex, int x) throws SQLException;
public abstract void setLong (int parameterIndex, long x) throws SQLException;
public abstract void setNull (int parameterIndex, int sqlType) throws SQLException;
1.2public abstract void setNull (int paramIndex, int sqlType, String typeName) throws SQLException;
public abstract void setObject (int parameterIndex, Object x) throws SQLException;
public abstract void setObject (int parameterIndex, Object x, int targetSqlType) throws SQLException;
public abstract void setObject (int parameterIndex, Object x, int targetSqlType, int scale) throws SQLException;
1.2public abstract void setRef (int i, Ref x) throws SQLException;
public abstract void setShort (int parameterIndex, short x) throws SQLException;
public abstract void setString (int parameterIndex, String x) throws SQLException;
public abstract void setTime (int parameterIndex, Time x) throws SQLException;
1.2public abstract void setTime (int parameterIndex, Time x, java.util.Calendar cal) throws SQLException;
public abstract void setTimestamp (int parameterIndex, Timestamp x) throws SQLException;
1.2public abstract void setTimestamp (int parameterIndex, Timestamp x, java.util.Calendar cal) throws SQLException;
// Deprecated Public Methods
#public abstract void setUnicodeStream (int parameterIndex, java.io.InputStream x, int length) throws SQLException;
}

Hierarchy: (PreparedStatement(Statement))

Implementations: CallableStatement

Returned By: java.sql.Connection.prepareStatement()

RefJava 1.2
java.sql

The Ref interface provides a pointer to a structured data type within the database. The getBaseType() method returns the name of the underlying type.

public abstract interface Ref {
// Public Instance Methods
public abstract String getBaseTypeName () throws SQLException;
}

Passed To: PreparedStatement.setRef(), SQLOutput.writeRef(), javax.sql.RowSet.setRef()

Returned By: CallableStatement.getRef(), ResultSet.getRef(), SQLInput.readRef()

ResultSetJava 1.1
java.sqlPJ1.1(opt)

The ResultSet interface represents a database result set, allowing programs to access the data in the result set. ResultSet objects are usually generated by the execute(), executeUpdate(), and executeQuery() methods of Statement and PreparedStatement. They are also returned by certain metadata methods.

The JDBC 1.0 ResultSet allows you to scroll navigate through the data once from beginning to end, iterating through rows using the next() method and retrieving individual fields using the getXXX() methods. The getMetaData() method returns a ResultSetMetaData object that describes the structure of the underlying data.

JDBC 2.0 introduces a number of new features: complete scrolling capabilities (the previous(), first(), last(), and related methods), direct updating of data via the updateXXX() methods, and insertion of new data rows using the insertRow() method. Since there are relatively few JDBC 2.0-compliant drivers (currently available as of this book's print date), you may want to avoid the JDBC 2.0 methods for the time being.

public abstract interface ResultSet {
// Public Constants
1.2public static final int CONCUR_READ_ONLY ; =1007
1.2public static final int CONCUR_UPDATABLE ; =1008
1.2public static final int FETCH_FORWARD ; =1000
1.2public static final int FETCH_REVERSE ; =1001
1.2public static final int FETCH_UNKNOWN ; =1002
1.2public static final int TYPE_FORWARD_ONLY ; =1003
1.2public static final int TYPE_SCROLL_INSENSITIVE ; =1004
1.2public static final int TYPE_SCROLL_SENSITIVE ; =1005
// Public Instance Methods
1.2public abstract boolean absolute (int row) throws SQLException;
1.2public abstract void afterLast () throws SQLException;
1.2public abstract void beforeFirst () throws SQLException;
1.2public abstract void cancelRowUpdates () throws SQLException;
public abstract void clearWarnings () throws SQLException;
public abstract void close () throws SQLException;
1.2public abstract void deleteRow () throws SQLException;
public abstract int findColumn (String columnName) throws SQLException;
1.2public abstract boolean first () throws SQLException;
1.2public abstract java.sql.Array getArray (String colName) throws SQLException;
1.2public abstract java.sql.Array getArray (int i) throws SQLException;
public abstract java.io.InputStream getAsciiStream (String columnName) throws SQLException;
public abstract java.io.InputStream getAsciiStream (int columnIndex) throws SQLException;
1.2public abstract java.math.BigDecimal getBigDecimal (String columnName) throws SQLException;
1.2public abstract java.math.BigDecimal getBigDecimal (int columnIndex) throws SQLException;
public abstract java.io.InputStream getBinaryStream (String columnName) throws SQLException;
public abstract java.io.InputStream getBinaryStream (int columnIndex) throws SQLException;
1.2public abstract Blob getBlob (String colName) throws SQLException;
1.2public abstract Blob getBlob (int i) throws SQLException;
public abstract boolean getBoolean (String columnName) throws SQLException;
public abstract boolean getBoolean (int columnIndex) throws SQLException;
public abstract byte getByte (String columnName) throws SQLException;
public abstract byte getByte (int columnIndex) throws SQLException;
public abstract byte[ ] getBytes (String columnName) throws SQLException;
public abstract byte[ ] getBytes (int columnIndex) throws SQLException;
1.2public abstract Reader getCharacterStream (String columnName) throws SQLException;
1.2public abstract Reader getCharacterStream (int columnIndex) throws SQLException;
1.2public abstract Clob getClob (String colName) throws SQLException;
1.2public abstract Clob getClob (int i) throws SQLException;
1.2public abstract int getConcurrency () throws SQLException;
public abstract String getCursorName () throws SQLException;
public abstract java.sql.Date getDate (String columnName) throws SQLException;
public abstract java.sql.Date getDate (int columnIndex) throws SQLException;
1.2public abstract java.sql.Date getDate (String columnName, java.util.Calendar cal) throws SQLException;
1.2public abstract java.sql.Date getDate (int columnIndex, java.util.Calendar cal) throws SQLException;
public abstract double getDouble (String columnName) throws SQLException;
public abstract double getDouble (int columnIndex) throws SQLException;
1.2public abstract int getFetchDirection () throws SQLException;
1.2public abstract int getFetchSize () throws SQLException;
public abstract float getFloat (String columnName) throws SQLException;
public abstract float getFloat (int columnIndex) throws SQLException;
public abstract int getInt (String columnName) throws SQLException;
public abstract int getInt (int columnIndex) throws SQLException;
public abstract long getLong (String columnName) throws SQLException;
public abstract long getLong (int columnIndex) throws SQLException;
public abstract ResultSetMetaData getMetaData () throws SQLException;
public abstract Object getObject (String columnName) throws SQLException;
public abstract Object getObject (int columnIndex) throws SQLException;
1.2public abstract Object getObject (String colName, java.util.Map map) throws SQLException;
1.2public abstract Object getObject (int i, java.util.Map map) throws SQLException;
1.2public abstract Ref getRef (String colName) throws SQLException;
1.2public abstract Ref getRef (int i) throws SQLException;
1.2public abstract int getRow () throws SQLException;
public abstract short getShort (String columnName) throws SQLException;
public abstract short getShort (int columnIndex) throws SQLException;
1.2public abstract Statement getStatement () throws SQLException;
public abstract String getString (String columnName) throws SQLException;
public abstract String getString (int columnIndex) throws SQLException;
public abstract Time getTime (String columnName) throws SQLException;
public abstract Time getTime (int columnIndex) throws SQLException;
1.2public abstract Time getTime (String columnName, java.util.Calendar cal) throws SQLException;
1.2public abstract Time getTime (int columnIndex, java.util.Calendar cal) throws SQLException;
public abstract Timestamp getTimestamp (String columnName) throws SQLException;
public abstract Timestamp getTimestamp (int columnIndex) throws SQLException;
1.2public abstract Timestamp getTimestamp (String columnName, java.util.Calendar cal) throws SQLException;
1.2public abstract Timestamp getTimestamp (int columnIndex, java.util.Calendar cal) throws SQLException;
1.2public abstract int getType () throws SQLException;
public abstract SQLWarning getWarnings () throws SQLException;
1.2public abstract void insertRow () throws SQLException;
1.2public abstract boolean isAfterLast () throws SQLException;
1.2public abstract boolean isBeforeFirst () throws SQLException;
1.2public abstract boolean isFirst () throws SQLException;
1.2public abstract boolean isLast () throws SQLException;
1.2public abstract boolean last () throws SQLException;
1.2public abstract void moveToCurrentRow () throws SQLException;
1.2public abstract void moveToInsertRow () throws SQLException;
public abstract boolean next () throws SQLException;
1.2public abstract boolean previous () throws SQLException;
1.2public abstract void refreshRow () throws SQLException;
1.2public abstract boolean relative (int rows) throws SQLException;
1.2public abstract boolean rowDeleted () throws SQLException;
1.2public abstract boolean rowInserted () throws SQLException;
1.2public abstract boolean rowUpdated () throws SQLException;
1.2public abstract void setFetchDirection (int direction) throws SQLException;
1.2public abstract void setFetchSize (int rows) throws SQLException;
1.2public abstract void updateAsciiStream (String columnName, java.io.InputStream x, int length) throws SQLException;
1.2public abstract void updateAsciiStream (int columnIndex, java.io.InputStream x, int length) throws SQLException;
1.2public abstract void updateBigDecimal (String columnName, java.math.BigDecimal x) throws SQLException;
1.2public abstract void updateBigDecimal (int columnIndex, java.math.BigDecimal x) throws SQLException;
1.2public abstract void updateBinaryStream (String columnName, java.io.InputStream x, int length) throws SQLException;
1.2public abstract void updateBinaryStream (int columnIndex, java.io.InputStream x, int length) throws SQLException;
1.2public abstract void updateBoolean (String columnName, boolean x) throws SQLException;
1.2public abstract void updateBoolean (int columnIndex, boolean x) throws SQLException;
1.2public abstract void updateByte (String columnName, byte x) throws SQLException;
1.2public abstract void updateByte (int columnIndex, byte x) throws SQLException;
1.2public abstract void updateBytes (String columnName, byte[ ] x) throws SQLException;
1.2public abstract void updateBytes (int columnIndex, byte[ ] x) throws SQLException;
1.2public abstract void updateCharacterStream (String columnName, Reader reader, int length) throws SQLException;
1.2public abstract void updateCharacterStream (int columnIndex, Reader x, int length) throws SQLException;
1.2public abstract void updateDate (String columnName, java.sql.Date x) throws SQLException;
1.2public abstract void updateDate (int columnIndex, java.sql.Date x) throws SQLException;
1.2public abstract void updateDouble (String columnName, double x) throws SQLException;
1.2public abstract void updateDouble (int columnIndex, double x) throws SQLException;
1.2public abstract void updateFloat (String columnName, float x) throws SQLException;
1.2public abstract void updateFloat (int columnIndex, float x) throws SQLException;
1.2public abstract void updateInt (String columnName, int x) throws SQLException;
1.2public abstract void updateInt (int columnIndex, int x) throws SQLException;
1.2public abstract void updateLong (String columnName, long x) throws SQLException;
1.2public abstract void updateLong (int columnIndex, long x) throws SQLException;
1.2public abstract void updateNull (String columnName) throws SQLException;
1.2public abstract void updateNull (int columnIndex) throws SQLException;
1.2public abstract void updateObject (String columnName, Object x) throws SQLException;
1.2public abstract void updateObject (int columnIndex, Object x) throws SQLException;
1.2public abstract void updateObject (String columnName, Object x, int scale) throws SQLException;
1.2public abstract void updateObject (int columnIndex, Object x, int scale) throws SQLException;
1.2public abstract void updateRow () throws SQLException;
1.2public abstract void updateShort (String columnName, short x) throws SQLException;
1.2public abstract void updateShort (int columnIndex, short x) throws SQLException;
1.2public abstract void updateString (String columnName, String x) throws SQLException;
1.2public abstract void updateString (int columnIndex, String x) throws SQLException;
1.2public abstract void updateTime (String columnName, Time x) throws SQLException;
1.2public abstract void updateTime (int columnIndex, Time x) throws SQLException;
1.2public abstract void updateTimestamp (String columnName, Timestamp x) throws SQLException;
1.2public abstract void updateTimestamp (int columnIndex, Timestamp x) throws SQLException;
public abstract boolean wasNull () throws SQLException;
// Deprecated Public Methods
#public abstract java.math.BigDecimal getBigDecimal (String columnName, int scale) throws SQLException;
#public abstract java.math.BigDecimal getBigDecimal (int columnIndex, int scale) throws SQLException;
#public abstract java.io.InputStream getUnicodeStream (String columnName) throws SQLException;
#public abstract java.io.InputStream getUnicodeStream (int columnIndex) throws SQLException;
}

Implementations: javax.sql.RowSet

Returned By: Too many methods to list.

ResultSetMetaDataJava 1.1
java.sqlPJ1.1(opt)

This interface provides metainformation about the data underlying a particular ResultSet. In particular, you can get information about the columns of the ResultSet with getColumnCount(), getColumnLabel(), and getColumnTypeName().

public abstract interface ResultSetMetaData {
// Public Constants
public static final int columnNoNulls ; =0
public static final int columnNullable ; =1
public static final int columnNullableUnknown ; =2
// Public Instance Methods
public abstract String getCatalogName (int column) throws SQLException;
1.2public abstract String getColumnClassName (int column) throws SQLException;
public abstract int getColumnCount () throws SQLException;
public abstract int getColumnDisplaySize (int column) throws SQLException;
public abstract String getColumnLabel (int column) throws SQLException;
public abstract String getColumnName (int column) throws SQLException;
public abstract int getColumnType (int column) throws SQLException;
public abstract String getColumnTypeName (int column) throws SQLException;
public abstract int getPrecision (int column) throws SQLException;
public abstract int getScale (int column) throws SQLException;
public abstract String getSchemaName (int column) throws SQLException;
public abstract String getTableName (int column) throws SQLException;
public abstract boolean isAutoIncrement (int column) throws SQLException;
public abstract boolean isCaseSensitive (int column) throws SQLException;
public abstract boolean isCurrency (int column) throws SQLException;
public abstract boolean isDefinitelyWritable (int column) throws SQLException;
public abstract int isNullable (int column) throws SQLException;
public abstract boolean isReadOnly (int column) throws SQLException;
public abstract boolean isSearchable (int column) throws SQLException;
public abstract boolean isSigned (int column) throws SQLException;
public abstract boolean isWritable (int column) throws SQLException;
}

Implementations: javax.sql.RowSetMetaData

Returned By: PreparedStatement.getMetaData(), ResultSet.getMetaData()

SQLDataJava 1.2
java.sql

Allows custom mapping of user-defined SQL types. This interface is generally implemented by a development tool or driver vendor and is never called by the programmer directly.

public abstract interface SQLData {
// Public Instance Methods
public abstract String getSQLTypeName () throws SQLException;
public abstract void readSQL (SQLInput stream, String typeName) throws SQLException;
public abstract void writeSQL (SQLOutput stream) throws SQLException;
}

Passed To: SQLOutput.writeObject()

SQLExceptionJava 1.1
java.sqlserializable checked PJ1.1(opt)

A SQLException object is thrown by any JDBC method that encounters an error. SQLException extends the java.lang.Exception class and adds a vendor-specific error code and an XOPEN SQL state code. SQLException objects can be chained together. The next exception in the chain is retrieved via getNextException(), which returns null if there are no more exceptions available. The setNextException() method adds an exception to the end of the chain.

public class SQLException extends Exception {
// Public Constructors
public SQLException ();
public SQLException (String reason);
public SQLException (String reason, String SQLState);
public SQLException (String reason, String SQLState, int vendorCode);
// Public Instance Methods
public int getErrorCode (); default:0
public SQLException getNextException (); default:null
public String getSQLState (); default:null
public void setNextException (SQLException ex); synchronized
}

Hierarchy: Object-->Throwable(Serializable)-->Exception-->SQLException

Subclasses: BatchUpdateException, SQLWarning

Passed To: SQLException.setNextException(), javax.sql.ConnectionEvent.ConnectionEvent()

Returned By: SQLException.getNextException(), javax.sql.ConnectionEvent.getSQLException()

Thrown By: Too many methods to list.

SQLInputJava 1.2
java.sql

Represents an input stream for a user-defined SQL type. SQLInput is used by the driver and is never called by the programmer directly.

public abstract interface SQLInput {
// Public Instance Methods
public abstract java.sql.Array readArray () throws SQLException;
public abstract java.io.InputStream readAsciiStream () throws SQLException;
public abstract java.math.BigDecimal readBigDecimal () throws SQLException;
public abstract java.io.InputStream readBinaryStream () throws SQLException;
public abstract Blob readBlob () throws SQLException;
public abstract boolean readBoolean () throws SQLException;
public abstract byte readByte () throws SQLException;
public abstract byte[ ] readBytes () throws SQLException;
public abstract Reader readCharacterStream () throws SQLException;
public abstract Clob readClob () throws SQLException;
public abstract java.sql.Date readDate () throws SQLException;
public abstract double readDouble () throws SQLException;
public abstract float readFloat () throws SQLException;
public abstract int readInt () throws SQLException;
public abstract long readLong () throws SQLException;
public abstract Object readObject () throws SQLException;
public abstract Ref readRef () throws SQLException;
public abstract short readShort () throws SQLException;
public abstract String readString () throws SQLException;
public abstract Time readTime () throws SQLException;
public abstract Timestamp readTimestamp () throws SQLException;
public abstract boolean wasNull () throws SQLException;
}

Passed To: SQLData.readSQL()

SQLOutputJava 1.2
java.sql

Represents an output stream for a user-defined SQL type. SQLOutput is used by the driver and is never called by the programmer directly.

public abstract interface SQLOutput {
// Public Instance Methods
public abstract void writeArray (java.sql.Array x) throws SQLException;
public abstract void writeAsciiStream (java.io.InputStream x) throws SQLException;
public abstract void writeBigDecimal (java.math.BigDecimal x) throws SQLException;
public abstract void writeBinaryStream (java.io.InputStream x) throws SQLException;
public abstract void writeBlob (Blob x) throws SQLException;
public abstract void writeBoolean (boolean x) throws SQLException;
public abstract void writeByte (byte x) throws SQLException;
public abstract void writeBytes (byte[ ] x) throws SQLException;
public abstract void writeCharacterStream (Reader x) throws SQLException;
public abstract void writeClob (Clob x) throws SQLException;
public abstract void writeDate (java.sql.Date x) throws SQLException;
public abstract void writeDouble (double x) throws SQLException;
public abstract void writeFloat (float x) throws SQLException;
public abstract void writeInt (int x) throws SQLException;
public abstract void writeLong (long x) throws SQLException;
public abstract void writeObject (SQLData x) throws SQLException;
public abstract void writeRef (Ref x) throws SQLException;
public abstract void writeShort (short x) throws SQLException;
public abstract void writeString (String x) throws SQLException;
public abstract void writeStruct (Struct x) throws SQLException;
public abstract void writeTime (Time x) throws SQLException;
public abstract void writeTimestamp (Timestamp x) throws SQLException;
}

Passed To: SQLData.writeSQL()

SQLWarningJava 1.1
java.sqlserializable checked PJ1.1(opt)

Represents a nonfatal warning condition. Warnings are silently chained to the object whose method produced them. You can retrieve warnings with the getWarnings() method implemented by most JDBC classes.

public class SQLWarning extends SQLException {
// Public Constructors
public SQLWarning ();
public SQLWarning (String reason);
public SQLWarning (String reason, String SQLstate);
public SQLWarning (String reason, String SQLstate, int vendorCode);
// Public Instance Methods
public SQLWarning getNextWarning (); default:null
public void setNextWarning (SQLWarning w);
}

Hierarchy: Object-->Throwable(Serializable)-->Exception-->SQLException-->SQLWarning

Subclasses: DataTruncation

Passed To: SQLWarning.setNextWarning()

Returned By: java.sql.Connection.getWarnings(), ResultSet.getWarnings(), SQLWarning.getNextWarning(), Statement.getWarnings()

StatementJava 1.1
java.sqlPJ1.1(opt)

The Statement interface executes SQL statements. Statement objects are returned by the createStatement() method of Connection. The execute(), executeUpdate(), and executeQuery() methods each take a Stringparameter that contains a SQL statement. execute() returns a boolean value that indicates whether a ResultSet is available. The ResultSet can then be retrieved with getResultSet(). executeUpdate() returns an update count and is used for INSERT, UPDATE, DELETE, and other data manipulation statements. executeQuery() is used for SELECTstatements, so it returns a ResultSet. There can be only one ResultSet active per query; the current ResultSet is closed when a new SQL statement of any kind is executed.

public abstract interface Statement {
// Public Instance Methods
1.2public abstract void addBatch (String sql) throws SQLException;
public abstract void cancel () throws SQLException;
1.2public abstract void clearBatch () throws SQLException;
public abstract void clearWarnings () throws SQLException;
public abstract void close () throws SQLException;
public abstract boolean execute (String sql) throws SQLException;
1.2public abstract int[ ] executeBatch () throws SQLException;
public abstract ResultSet executeQuery (String sql) throws SQLException;
public abstract int executeUpdate (String sql) throws SQLException;
1.2public abstract java.sql.Connection getConnection () throws SQLException;
1.2public abstract int getFetchDirection () throws SQLException;
1.2public abstract int getFetchSize () throws SQLException;
public abstract int getMaxFieldSize () throws SQLException;
public abstract int getMaxRows () throws SQLException;
public abstract boolean getMoreResults () throws SQLException;
public abstract int getQueryTimeout () throws SQLException;
public abstract ResultSet getResultSet () throws SQLException;
1.2public abstract int getResultSetConcurrency () throws SQLException;
1.2public abstract int getResultSetType () throws SQLException;
public abstract int getUpdateCount () throws SQLException;
public abstract SQLWarning getWarnings () throws SQLException;
public abstract void setCursorName (String name) throws SQLException;
public abstract void setEscapeProcessing (boolean enable) throws SQLException;
1.2public abstract void setFetchDirection (int direction) throws SQLException;
1.2public abstract void setFetchSize (int rows) throws SQLException;
public abstract void setMaxFieldSize (int max) throws SQLException;
public abstract void setMaxRows (int max) throws SQLException;
public abstract void setQueryTimeout (int seconds) throws SQLException;
}

Implementations: PreparedStatement

Returned By: java.sql.Connection.createStatement(), ResultSet.getStatement()

StructJava 1.2
java.sql

The Struct interface provides a mapping for an SQL structured type. The getAttributes() method returns an array of objects representing each attribute in the structured type. Custom type maps can be specified by including a java.util.Map attribute.

public abstract interface Struct {
// Public Instance Methods
public abstract Object[ ] getAttributes () throws SQLException;
public abstract Object[ ] getAttributes (java.util.Map map) throws SQLException;
public abstract String getSQLTypeName () throws SQLException;
}

Passed To: SQLOutput.writeStruct()

TimeJava 1.1
java.sqlcloneable serializable comparable PJ1.1(opt)

A wrapper around the java.util.Date class that adjusts the time value (milliseconds since January 1, 1970 0:00:00 GMT) to conform to the SQL TIME specification. The TIME type only deals with the time of day, so the date components are set to January 1, 1970 and should not be altered. The Time class also includes a static valueOf() method that decodes the JDBC Time escape syntax hh:mm:ss into a Time value.

public class Time extends java.util.Date {
// Public Constructors
public Time (long time);
public Time (int hour, int minute, int second);
// Public Class Methods
public static Time valueOf (String s);
// Public methods overriding Date
public void setTime (long time);
public String toString ();
// Deprecated Public Methods
#public int getDate (); Overrides:Date
#public int getDay (); Overrides:Date
#public int getMonth (); Overrides:Date
#public int getYear (); Overrides:Date
#public void setDate (int i); Overrides:Date
#public void setMonth (int i); Overrides:Date
#public void setYear (int i); Overrides:Date
}

Hierarchy: Object-->java.util.Date(Serializable,Cloneable,Comparable)-->Time

Passed To: PreparedStatement.setTime(), ResultSet.updateTime(), SQLOutput.writeTime(), javax.sql.RowSet.setTime()

Returned By: CallableStatement.getTime(), ResultSet.getTime(), SQLInput.readTime(), Time.valueOf()

TimestampJava 1.1
java.sqlcloneable serializable comparable PJ1.1(opt)

Extends the java.util.Date class to function as an SQL TIMESTAMP value by adding a nanoseconds component. The getTime() method returns the time in milliseconds since January 1, 1970 00:00:00 GMT to the latest integral second. To include fractional seconds, divide the value returned by getNanos() by 1 million and add this to the result returned by getTime(). This allows accurate comparisons with java.util.Date objects. The valueOf() method parses a String in the format yyyy-mm-ddhh:mm:ss.fffffffff into a Timestamp.

public class Timestamp extends java.util.Date {
// Public Constructors
public Timestamp (long time);
#public Timestamp (int year, int month, int date, int hour, int minute, int second, int nano);
// Public Class Methods
public static Timestamp valueOf (String s);
// Public Instance Methods
public boolean after (Timestamp ts);
public boolean before (Timestamp ts);
public boolean equals (Timestamp ts);
public int getNanos ();
public void setNanos (int n);
// Public methods overriding Date
1.2public boolean equals (Object ts);
public String toString ();
}

Hierarchy: Object-->java.util.Date(Serializable,Cloneable,Comparable)-->Timestamp

Passed To: PreparedStatement.setTimestamp(), ResultSet.updateTimestamp(), SQLOutput.writeTimestamp(), Timestamp.{after(), before(), equals()}, javax.sql.RowSet.setTimestamp()

Returned By: CallableStatement.getTimestamp(), ResultSet.getTimestamp(), SQLInput.readTimestamp(), Timestamp.valueOf()

TypesJava 1.1
java.sqlPJ1.1(opt)

The Types class defines a set of integer constants that represent SQL data types. The type names and constant values are the ones specified in the XOPEN specification.

public class Types {
// No Constructor
// Public Constants
1.2public static final int ARRAY ; =2003
public static final int BIGINT ; =-5
public static final int BINARY ; =-2
public static final int BIT ; =-7
1.2public static final int BLOB ; =2004
public static final int CHAR ; =1
1.2public static final int CLOB ; =2005
public static final int DATE ; =91
public static final int DECIMAL ; =3
1.2public static final int DISTINCT ; =2001
public static final int DOUBLE ; =8
public static final int FLOAT ; =6
public static final int INTEGER ; =4
1.2public static final int JAVA_OBJECT ; =2000
public static final int LONGVARBINARY ; =-4
public static final int LONGVARCHAR ; =-1
public static final int NULL ; =0
public static final int NUMERIC ; =2
public static final int OTHER ; =1111
public static final int REAL ; =7
1.2public static final int REF ; =2006
public static final int SMALLINT ; =5
1.2public static final int STRUCT ; =2002
public static final int TIME ; =92
public static final int TIMESTAMP ; =93
public static final int TINYINT ; =-6
public static final int VARBINARY ; =-3
public static final int VARCHAR ; =12
}


Library Navigation Links

Copyright © 2001 O'Reilly & Associates. All rights reserved.