diff options
author | Warren Levy <warrenl@cygnus.com> | 2000-12-01 01:48:34 +0000 |
---|---|---|
committer | Warren Levy <warrenl@gcc.gnu.org> | 2000-12-01 01:48:34 +0000 |
commit | 6934615b9736d0a777ce7f6933129ea1cdd2dd23 (patch) | |
tree | 7c67e6325a21b9cf53bbdc5648f2e7523a514436 /libjava | |
parent | 95ac07b0f4d9916c7a850e3b427cbc768819d742 (diff) | |
download | gcc-6934615b9736d0a777ce7f6933129ea1cdd2dd23.zip gcc-6934615b9736d0a777ce7f6933129ea1cdd2dd23.tar.gz gcc-6934615b9736d0a777ce7f6933129ea1cdd2dd23.tar.bz2 |
Array.java: New file from classpath.
* Array.java: New file from classpath.
* BatchUpdateException.java: Ditto.
* Blob.java: Ditto.
* Clob.java: Ditto.
* Ref.java: Ditto.
* SQLData.java: Ditto.
* SQLInput.java: Ditto.
* SQLOutput.java: Ditto.
* Struct.java: Ditto.
* CallableStatement.java: Merged file from claspath.
* Connection.java: Ditto.
* DataTruncation.java: Ditto.
* DatabaseMetaData.java: Ditto.
* DriverManager.java: Ditto.
* PreparedStatement.java: Ditto.
* ResultSet.java: Ditto.
* ResultSetMetaData.java: Ditto.
* SQLException.java: Ditto.
* SQLWarning.java: Ditto.
* Statement.java: Ditto.
* Types.java: Ditto.
From-SVN: r37906
Diffstat (limited to 'libjava')
-rw-r--r-- | libjava/ChangeLog | 24 | ||||
-rw-r--r-- | libjava/java/sql/Array.java | 226 | ||||
-rw-r--r-- | libjava/java/sql/BatchUpdateException.java | 169 | ||||
-rw-r--r-- | libjava/java/sql/Blob.java | 120 | ||||
-rw-r--r-- | libjava/java/sql/CallableStatement.java | 157 | ||||
-rw-r--r-- | libjava/java/sql/Clob.java | 136 | ||||
-rw-r--r-- | libjava/java/sql/Connection.java | 111 | ||||
-rw-r--r-- | libjava/java/sql/DataTruncation.java | 11 | ||||
-rw-r--r-- | libjava/java/sql/DatabaseMetaData.java | 271 | ||||
-rw-r--r-- | libjava/java/sql/DriverManager.java | 63 | ||||
-rw-r--r-- | libjava/java/sql/PreparedStatement.java | 159 | ||||
-rw-r--r-- | libjava/java/sql/Ref.java | 51 | ||||
-rw-r--r-- | libjava/java/sql/ResultSet.java | 1326 | ||||
-rw-r--r-- | libjava/java/sql/ResultSetMetaData.java | 18 | ||||
-rw-r--r-- | libjava/java/sql/SQLData.java | 74 | ||||
-rw-r--r-- | libjava/java/sql/SQLException.java | 11 | ||||
-rw-r--r-- | libjava/java/sql/SQLInput.java | 332 | ||||
-rw-r--r-- | libjava/java/sql/SQLOutput.java | 331 | ||||
-rw-r--r-- | libjava/java/sql/SQLWarning.java | 15 | ||||
-rw-r--r-- | libjava/java/sql/Statement.java | 138 | ||||
-rw-r--r-- | libjava/java/sql/Struct.java | 80 | ||||
-rw-r--r-- | libjava/java/sql/Types.java | 7 |
22 files changed, 3810 insertions, 20 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 57c04e0..85dcf04 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,27 @@ +2000-11-30 Warren Levy <warrenl@cygnus.com> + + * Array.java: New file from classpath. + * BatchUpdateException.java: Ditto. + * Blob.java: Ditto. + * Clob.java: Ditto. + * Ref.java: Ditto. + * SQLData.java: Ditto. + * SQLInput.java: Ditto. + * SQLOutput.java: Ditto. + * Struct.java: Ditto. + * CallableStatement.java: Merged file from claspath. + * Connection.java: Ditto. + * DataTruncation.java: Ditto. + * DatabaseMetaData.java: Ditto. + * DriverManager.java: Ditto. + * PreparedStatement.java: Ditto. + * ResultSet.java: Ditto. + * ResultSetMetaData.java: Ditto. + * SQLException.java: Ditto. + * SQLWarning.java: Ditto. + * Statement.java: Ditto. + * Types.java: Ditto. + 2000-11-29 Bryce McKinlay <bryce@albatross.co.nz> * java/lang/natSystem.cc (init_properties): Set user.language and diff --git a/libjava/java/sql/Array.java b/libjava/java/sql/Array.java new file mode 100644 index 0000000..0043f93 --- /dev/null +++ b/libjava/java/sql/Array.java @@ -0,0 +1,226 @@ +/* Array.java -- Interface for accessing SQL array object + Copyright (C) 1999, 2000 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ + + +package java.sql; + +import java.util.Map; + +/** + * This interface provides methods for accessing SQL array types + * + * @author Aaron M. Renn (arenn@urbanophile.com) + */ +public interface Array +{ + +/** + * This method returns the name of the SQL type of the elements in this + * array. This name is database specific. + * + * @param The name of the SQL type of the elements in this array. + * + * @exception SQLException If an error occurs. + */ +public abstract String +getBaseTypeName() throws SQLException; + +/*************************************************************************/ + +/** + * This method returns the JDBC type identifier of the elements in this + * array. This will be one of the values defined in the <code>Types</code> + * class. + * + * @return The JDBC type of the elements in this array. + * + * @exception SQLException If an error occurs. + * + * @see Types + */ +public abstract int +getBaseType() throws SQLException; + +/*************************************************************************/ + +/** + * This method returns the contents of this array. This object returned + * will be an array of Java objects of the appropriate types. + * + * @return The contents of the array as an array of Java objects. + * + * @exception SQLException If an error occurs. + */ +public abstract Object +getArray() throws SQLException; + +/*************************************************************************/ + +/** + * This method returns the contents of this array. The specified + * <code>Map</code> will be used to override selected mappings between + * SQL types and Java classes. + * + * @param map A mapping of SQL types to Java classes. + * + * @return The contents of the array as an array of Java objects. + * + * @exception SQLException If an error occurs. + */ +public abstract Object +getArray(Map map) throws SQLException; + +/*************************************************************************/ + +/** + * This method returns a portion of this array starting at index + * <code>offset</code> into the array and continuing for <code>length</code> + * elements. Fewer than the requested number of elements will be + * returned if the array does not contain the requested number of elements. + * The object returned will be an array of Java objects of + * the appropriate types. + * + * @param offset The offset into this array to start returning elements from. + * @param count The requested number of elements to return. + * + * @return The requested portion of the array. + * + * @exception SQLException If an error occurs. + */ +public abstract Object +getArray(long offset, int count) throws SQLException; + +/*************************************************************************/ + +/** + * This method returns a portion of this array starting at index + * <code>offset</code> into the array and continuing for <code>length</code> + * elements. Fewer than the requested number of elements will be + * returned if the array does not contain the requested number of elements. + * The object returned will be an array of Java objects. The specified + * <code>Map</code> will be used for overriding selected SQL type to + * Java class mappings. + * + * @param offset The offset into this array to start returning elements from. + * @param count The requested number of elements to return. + * @param map A mapping of SQL types to Java classes. + * + * @return The requested portion of the array. + * + * @exception SQLException If an error occurs. + */ +public abstract Object +getArray(long index, int count, Map map) throws SQLException; + +/*************************************************************************/ + +/** + * This method returns the elements in the array as a <code>ResultSet</code>. + * Each row of the result set will have two columns. The first will be + * the index into the array of that row's contents. The second will be + * the actual value of that array element. + * + * @return The elements of this array as a <code>ResultSet</code>. + * + * @exception SQLException If an error occurs. + * + * @see ResultSet + */ +public abstract ResultSet +getResultSet() throws SQLException; + +/*************************************************************************/ + +/** + * This method returns the elements in the array as a <code>ResultSet</code>. + * Each row of the result set will have two columns. The first will be + * the index into the array of that row's contents. The second will be + * the actual value of that array element. The specified <code>Map</code> + * will be used to override selected default mappings of SQL types to + * Java classes. + * + * @param map A mapping of SQL types to Java classes. + * + * @return The elements of this array as a <code>ResultSet</code>. + * + * @exception SQLException If an error occurs. + * + * @see ResultSet + */ +public abstract ResultSet +getResultSet(Map map) throws SQLException; + +/*************************************************************************/ + +/** + * This method returns a portion of the array as a <code>ResultSet</code>. + * The returned portion will start at index <code>offset</code> into the + * array and up to <code>length</code> elements will be returned. + * <p> + * Each row of the result set will have two columns. The first will be + * the index into the array of that row's contents. The second will be + * the actual value of that array element. + * + * @param offset The index into the array to start returning elements from. + * @param length The requested number of elements to return. + * + * @return The requested elements of this array as a <code>ResultSet</code>. + * + * @exception SQLException If an error occurs. + * + * @see ResultSet + */ +public abstract ResultSet +getResultSet(long index, int count) throws SQLException; + +/*************************************************************************/ + +/** + * This method returns a portion of the array as a <code>ResultSet</code>. + * The returned portion will start at index <code>offset</code> into the + * array and up to <code>length</code> elements will be returned. + * <p> + * Each row of the result set will have two columns. The first will be + * the index into the array of that row's contents. The second will be + * the actual value of that array element. The specified <code>Map</code> + * will be used to override selected default mappings of SQL types to + * Java classes. + * + * @param offset The index into the array to start returning elements from. + * @param length The requested number of elements to return. + * @param map A mapping of SQL types to Java classes. + * + * @return The requested elements of this array as a <code>ResultSet</code>. + * + * @exception SQLException If an error occurs. + * + * @see ResultSet + */ +public abstract ResultSet +getResultSet(long index, int count, Map map) throws SQLException; + +} // interface Array + diff --git a/libjava/java/sql/BatchUpdateException.java b/libjava/java/sql/BatchUpdateException.java new file mode 100644 index 0000000..ff325b4 --- /dev/null +++ b/libjava/java/sql/BatchUpdateException.java @@ -0,0 +1,169 @@ +/* BatchUpdateException.java -- Exception for batch oriented SQL errors + Copyright (C) 1999, 2000 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ + + +package java.sql; + +/** + * This class extends <code>SQLException</code> to count the successful + * updates in each statement in a batch that was successfully updated prior + * to the error. + * + * @author Aaron M. Renn (arenn@urbanophile.com) + */ +public class BatchUpdateException extends SQLException +{ + +/*************************************************************************/ + +/* + * Instance Variables + */ + +/** + * This is the array of update counts for the commands which completed + * successfully prior to the error. + * @serialized + */ +private int[] updateCounts; + +/*************************************************************************/ + +/* + * Constructors + */ + +/** + * This method initializes a new instance of <code>BatchUpdateException</code> + * with no descriptive error message. The SQL state and update count will + * be initialized to <code>null</code> and the vendor specific error code will + * initialized to 0. + */ +public +BatchUpdateException() +{ + super(); +} + +/*************************************************************************/ + +/** + * This method initializes a new instance of <code>BatchUpdateException</code> + * with the specified update count information and no descriptive error + * message. This SQL state will be initialized to <code>null</code> and + * the vendor specific error code will be initialized to 0. + * + * @param updateCounts The update count array. + */ +public +BatchUpdateException(int[] updateCounts) +{ + super(); + + this.updateCounts = updateCounts; +} + +/*************************************************************************/ + +/** + * This method initializes a new instance of <code>BatchUpdateException</code> + * with the specified descriptive error message and update count information. + * The SQL state will be initialized to <code>null</code> and the vendor + * specific error code will be initialized to 0. + * + * @param message The descriptive error message. + * @param updateCounts The update count information for this error. + */ +public +BatchUpdateException(String message, int[] updateCounts) +{ + super(message); + + this.updateCounts = updateCounts; +} + +/*************************************************************************/ + +/** + * This method initializes a new instance of <code>BatchUpdateException</code> + * with the specified descriptive error message, SQL state, and update count + * information. The vendor specific error code will be initialized to 0. + * + * @param message The descriptive error message. + * @param SQLState The SQL state information for this error. + * @param updateCounts The update count information for this error. + */ +public +BatchUpdateException(String message, String SQLState, int[] updateCounts) +{ + super(message, SQLState); + + this.updateCounts = updateCounts; +} + +/*************************************************************************/ + +/** + * This method initializes a new instance of <code>BatchUpdateException</code> + * with the specified descriptive error message, SQL state, vendor + * specific error code and update count information. + * + * @param message The descriptive error message. + * @param SQLState The SQL state information for this error. + * @param vendorCode The vendor specific error code for this error. + * @param updateCounts The update count information for this error. + */ +public +BatchUpdateException(String message, String SQLState, int vendorCode, + int[] updateCounts) +{ + super(message, SQLState, vendorCode); + + this.updateCounts = updateCounts; +} + +/*************************************************************************/ + +/* + * Instance Methods + */ + +/** + * This method returns the update count information for this error. If + * not <code>null</code> this is an array of <code>int</code>'s that are + * the update accounts for each command that was successfully executed. + * The array elements are in the order that the commands were executed. + * + * @return The update count information, which may be <code>null</code>. + */ +public int[] +getUpdateCounts() +{ + return(updateCounts); +} + +} // class BatchUpdateException + diff --git a/libjava/java/sql/Blob.java b/libjava/java/sql/Blob.java new file mode 100644 index 0000000..79a4504 --- /dev/null +++ b/libjava/java/sql/Blob.java @@ -0,0 +1,120 @@ +/* Blob.java -- Access a SQL Binary Large OBject. + Copyright (C) 1999, 2000 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ + + +package java.sql; + +import java.io.InputStream; + +/** + * This interface specified methods for accessing a SQL BLOB (Binary + * Large OBject) type. + * + * @author Aaron M. Renn (arenn@urbanophile.com) + */ +public interface Blob +{ + +/*************************************************************************/ + +/** + * This method returns the number of bytes in the BLOB. + * + * @return The number of bytes in the BLOB. + * + * @exception SQLException If an error occurs. + */ +public abstract long +length() throws SQLException; + +/*************************************************************************/ + +/** + * This method returns up to the requested bytes of this BLOB as a + * <code>byte</code> array. + * + * @param offset The index into the BLOB to start returning bytes from. + * @param length The requested number of bytes to return. + * + * @return The requested bytes from the BLOB. + * + * @exception SQLException If an error occurs. + */ +public abstract byte[] +getBytes(long offset, int length) throws SQLException; + +/*************************************************************************/ + +/** + * This method returns a stream that will read the bytes of the BLOB. + * + * @return A stream that will read the bytes of the BLOB. + * + * @exception SQLException If an error occurs. + */ +public abstract InputStream +getBinaryStream() throws SQLException; + +/*************************************************************************/ + +/** + * This method returns the index into the BLOB at which the first instance + * of the specified bytes occur. The searching starts at the specified + * index into the BLOB. + * + * @param pattern The byte pattern to search for. + * @param offset The index into the BLOB to starting searching for the pattern. + * + * @return The offset at which the pattern is first found, or -1 if the + * pattern is not found. + * + * @exception SQLException If an error occurs. + */ +public abstract long +position(byte[] pattern, long offset) throws SQLException; + +/*************************************************************************/ + +/** + * This method returns the index into the BLOB at which the first instance + * of the specified pattern occurs. The searching starts at the specified + * index into this BLOB. The bytes in the specified <code>Blob</code> are + * used as the search pattern. + * + * @param pattern The <code>Blob</code> containing the byte pattern to + * search for. + * @param offset The index into the BLOB to starting searching for the pattern. + * + * @return The offset at which the pattern is first found, or -1 if the + * pattern is not found. + * + * @exception SQLException If an error occurs. + */ +public abstract long +position(Blob pattern, long offset) throws SQLException; + +} // interface Blob + diff --git a/libjava/java/sql/CallableStatement.java b/libjava/java/sql/CallableStatement.java index 75a6054..9a1547e 100644 --- a/libjava/java/sql/CallableStatement.java +++ b/libjava/java/sql/CallableStatement.java @@ -1,5 +1,5 @@ /* CallableStatement.java -- A statement for calling stored procedures. - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 2000 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -31,6 +31,7 @@ import java.io.InputStream; import java.io.Reader; import java.math.BigDecimal; import java.util.Calendar; +import java.util.Map; /** * This interface provides a mechanism for calling stored procedures. @@ -88,6 +89,22 @@ getObject(int index) throws SQLException; /** * This method returns the value of the specified parameter as a Java + * <code>Object</code>. + * + * @param index The index of the parameter to return. + * @param map The mapping to use for conversion from SQL to Java types. + * + * @return The parameter value as an <code>Object</code>. + * + * @exception SQLException If an error occurs. + */ +public abstract Object +getObject(int index, Map map) throws SQLException; + +/*************************************************************************/ + +/** + * This method returns the value of the specified parameter as a Java * <code>boolean</code>. * * @param index The index of the parameter to return. @@ -196,6 +213,21 @@ getDouble(int index) throws SQLException; * <code>BigDecimal</code>. * * @param index The index of the parameter to return. + * + * @return The parameter value as a <code>BigDecimal</code>. + * + * @exception SQLException If an error occurs. + */ +public abstract BigDecimal +getBigDecimal(int index) throws SQLException; + +/*************************************************************************/ + +/** + * This method returns the value of the specified parameter as a Java + * <code>BigDecimal</code>. + * + * @param index The index of the parameter to return. * @param scale The number of digits to the right of the decimal to return. * * @return The parameter value as a <code>BigDecimal</code>. @@ -239,6 +271,22 @@ getDate(int index) throws SQLException; /** * This method returns the value of the specified parameter as a Java + * <code>java.sql.Date</code>. + * + * @param index The index of the parameter to return. + * @param calendar The <code>Calendar</code> to use for timezone and locale. + * + * @return The parameter value as a <code>java.sql.Date</code>. + * + * @exception SQLException If an error occurs. + */ +public abstract java.sql.Date +getDate(int index, Calendar calendar) throws SQLException; + +/*************************************************************************/ + +/** + * This method returns the value of the specified parameter as a Java * <code>java.sql.Time</code>. * * @param index The index of the parameter to return. @@ -254,6 +302,22 @@ getTime(int index) throws SQLException; /** * This method returns the value of the specified parameter as a Java + * <code>java.sql.Time</code>. + * + * @param index The index of the parameter to return. + * @param calendar The <code>Calendar</code> to use for timezone and locale. + * + * @return The parameter value as a <code>java.sql.Time</code>. + * + * @exception SQLException If an error occurs. + */ +public abstract java.sql.Time +getTime(int index, Calendar calendar) throws SQLException; + +/*************************************************************************/ + +/** + * This method returns the value of the specified parameter as a Java * <code>java.sql.Timestamp</code>. * * @param index The index of the parameter to return. @@ -268,6 +332,82 @@ getTimestamp(int index) throws SQLException; /*************************************************************************/ /** + * This method returns the value of the specified parameter as a Java + * <code>java.sql.Timestamp</code>. + * + * @param index The index of the parameter to return. + * @param calendar The <code>Calendar</code> to use for timezone and locale. + * + * @return The parameter value as a <code>java.sql.Timestamp</code>. + * + * @exception SQLException If an error occurs. + */ +public abstract java.sql.Timestamp +getTimestamp(int index, Calendar calendar) throws SQLException; + +/*************************************************************************/ + +/** + * This method returns the value of the specified parameter as a Java + * <code>Ref</code>. + * + * @param index The index of the parameter to return. + * + * @return The parameter value as a <code>Ref</code>. + * + * @exception SQLException If an error occurs. + */ +public abstract Ref +getRef(int index) throws SQLException; + +/*************************************************************************/ + +/** + * This method returns the value of the specified parameter as a Java + * <code>Blob</code>. + * + * @param index The index of the parameter to return. + * + * @return The parameter value as a <code>Blob</code>. + * + * @exception SQLException If an error occurs. + */ +public abstract Blob +getBlob(int index) throws SQLException; + +/*************************************************************************/ + +/** + * This method returns the value of the specified parameter as a Java + * <code>Clob</code>. + * + * @param index The index of the parameter to return. + * + * @return The parameter value as a <code>Clob</code>. + * + * @exception SQLException If an error occurs. + */ +public abstract Clob +getClob(int index) throws SQLException; + +/*************************************************************************/ + +/** + * This method returns the value of the specified parameter as a Java + * <code>Array</code>. + * + * @param index The index of the parameter to return. + * + * @return The parameter value as a <code>Array</code>. + * + * @exception SQLException If an error occurs. + */ +public abstract Array +getArray(int index) throws SQLException; + +/*************************************************************************/ + +/** * This method registers the specified parameter as an output parameter * of the specified SQL type. * @@ -283,6 +423,21 @@ registerOutParameter(int index, int type) throws SQLException; /** * This method registers the specified parameter as an output parameter + * of the specified SQL type. + * + * @param index The index of the parameter to register as output. + * @param type The SQL type value from <code>Types</code>. + * @param name The user defined data type name. + * + * @exception SQLException If an error occurs. + */ +public abstract void +registerOutParameter(int index, int type, String name) throws SQLException; + +/*************************************************************************/ + +/** + * This method registers the specified parameter as an output parameter * of the specified SQL type and scale. * * @param index The index of the parameter to register as output. diff --git a/libjava/java/sql/Clob.java b/libjava/java/sql/Clob.java new file mode 100644 index 0000000..a3298fe --- /dev/null +++ b/libjava/java/sql/Clob.java @@ -0,0 +1,136 @@ +/* Clob.java -- Access Character Large OBjects + Copyright (C) 1999, 2000 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ + + +package java.sql; + +import java.io.InputStream; +import java.io.Reader; + +/** + * This interface contains methods for accessing a SQL CLOB (Character + * Large OBject) type. + * + * @author Aaron M. Renn (arenn@urbanophile.com) + */ +public interface Clob +{ + +/** + * This method returns the number of characters in the CLOB. + * + * @return The number of characters in the CLOB. + * + * @exception SQLException If an error occurs. + */ +public abstract long +length() throws SQLException; + +/*************************************************************************/ + +/** + * This method returns the specified portion of the CLOB as a + * <code>String</code>. + * + * @param offset The index into the CLOB (index values start at 1) to + * start returning characters from. + * @param length The requested number of characters to return. + * + * @return The requested CLOB section, as a <code>String</code>. + * + * @exception SQLException If an error occurs. + */ +public abstract String +getSubString(long offset, int length) throws SQLException; + +/*************************************************************************/ + +/** + * This method returns a byte stream that reads the contents of the + * CLOB as a series of ASCII bytes. + * + * @return A stream to read the CLOB's contents. + * + * @exception SQLException If an error occurs. + */ +public abstract InputStream +getAsciiStream() throws SQLException; + +/*************************************************************************/ + +/** + * This method returns a character stream that reads the contents of the + * CLOB. + * + * @return A character stream to read the CLOB's contents. + * + * @exception SQLException If an error occurs. + */ +public abstract Reader +getCharacterStream() throws SQLException; + +/*************************************************************************/ + +/** + * This method returns the index into the CLOB of the first occurrence of + * the specified character pattern (supplied by the caller as a + * <code>String</code>). The search begins at the specified index. + * + * @param pattern The character pattern to search for, passed as a + * <code>String</code>. + * @param offset. The index into the CLOB to start search (indexes start + * at 1). + * + * @return The index at which the pattern was found (indexes start at 1), + * or -1 if the pattern was not found. + * + * @exception SQLException If an error occurs. + */ +public abstract long +position(String pattern, long offset) throws SQLException; + +/*************************************************************************/ + +/** + * This method returns the index into the CLOB of the first occurrence of + * the specified character pattern (supplied by the caller as a + * <code>Clob</code>). The search begins at the specified index. + * + * @param pattern The character pattern to search for, passed as a + * <code>Clob</code>. + * @param offset. The index into the CLOB to start search (indexes start + * at 1). + * + * @return The index at which the pattern was found (indexes start at 1), + * or -1 if the pattern was not found. + * + * @exception SQLException If an error occurs. + */ +public abstract long +position(Clob pattern, long offset) throws SQLException; + +} // interface Clob + diff --git a/libjava/java/sql/Connection.java b/libjava/java/sql/Connection.java index bb826a6..8d986aa 100644 --- a/libjava/java/sql/Connection.java +++ b/libjava/java/sql/Connection.java @@ -27,6 +27,8 @@ executable file might be covered by the GNU General Public License. */ package java.sql; +import java.util.Map; + /** * This interface provides methods for managing a connection to a database. * @@ -92,6 +94,28 @@ createStatement() throws SQLException; /*************************************************************************/ /** + * This method creates a new SQL statement with the specified type and + * concurrency. Valid values for these parameters are specified in the + * <code>ResultSet</code> class. + * + * @param resultSetType The type of result set to use for this statement. + * @param resultSetConcurrency. The type of concurrency to be used in + * the result set for this statement. + * + * @return A new <code>Statement</code> object. + * + * @exception SQLException If an error occurs. + * + * @see Statement + * @see ResultSet + */ +public abstract Statement +createStatement(int resultSetType, int resultSetConcurrency) + throws SQLException; + +/*************************************************************************/ + +/** * This method creates a new <code>PreparedStatement</code> for the specified * SQL string. This method is designed for use with parameterized * statements. The default result set type and concurrency will be used. @@ -111,6 +135,32 @@ prepareStatement(String sql) throws SQLException; /*************************************************************************/ /** + * This method creates a new <code>PreparedStatement</code> for the specified + * SQL string. This method is designed for use with parameterized + * statements. The specified result set type and concurrency will be used. + * Valid values for these parameters are specified in the + * <code>ResultSet</code> class. + * + * @param The SQL statement to use in creating this + * <code>PreparedStatement</code>. + * @param resultSetType The type of result set to use for this statement. + * @param resultSetConcurrency. The type of concurrency to be used in + * the result set for this statement. + * + * @return A new <code>PreparedStatement</code>. + * + * @exception SQLException If an error occurs. + * + * @see PreparedStatement + * @see ResultSet + */ +public abstract PreparedStatement +prepareStatement(String sql, int resultSetType, int resultSetConcurrency) + throws SQLException; + +/*************************************************************************/ + +/** * This method creates a new <code>CallableStatement</code> for the * specified SQL string. Thie method is designed to be used with * stored procedures. The default result set type and concurrency @@ -131,6 +181,32 @@ prepareCall(String sql) throws SQLException; /*************************************************************************/ /** + * This method creates a new <code>CallableStatement</code> for the + * specified SQL string. Thie method is designed to be used with + * stored procedures. The specified result set type and concurrency + * will be used. Valid values for these parameters are specified in the + * <code>ResultSet</code> class. + * + * @param The SQL statement to use in creating this + * <code>PreparedStatement</code>. + * @param resultSetType The type of result set to use for this statement. + * @param resultSetConcurrency. The type of concurrency to be used in + * the result set for this statement. + * + * @return A new <code>CallableStatement</code>. + * + * @exception SQLException If an error occurs. + * + * @see CallableStatement + * @see ResultSet + */ +public abstract CallableStatement +prepareCall(String sql, int resultSetType, int resultSetConcurrency) + throws SQLException; + +/*************************************************************************/ + +/** * This method converts the specified generic SQL statement into the * native grammer of the database this object is connected to. * @@ -309,12 +385,10 @@ getTransactionIsolation() throws SQLException; /*************************************************************************/ /** - * This method sets the transaction isolation level using one of the - * constants defined in this interface. + * This method sets the current transaction isolation mode. This must + * be one of the constants defined in this interface. * - * @param level The transaction isolation level to change to; must be - * one of the TRANSACTION_* isolation values with the exception of - * TRANSACTION_NONE; some databases may not support other values. + * @param level The transaction isolation level. * * @exception SQLException If an error occurs. */ @@ -346,5 +420,32 @@ getWarnings() throws SQLException; public abstract void clearWarnings() throws SQLException; +/*************************************************************************/ + +/** + * This method returns the mapping of SQL types to Java classes + * currently in use by this connection. This mapping will have no + * entries unless they have been manually added. + * + * @return The SQL type to Java class mapping. + * + * @exception SQLException If an error occurs. + */ +public abstract Map +getTypeMap() throws SQLException; + +/*************************************************************************/ + +/** + * This method sets the mapping table for SQL types to Java classes. + * Any entries in this map override the defaults. + * + * @param map The new SQL mapping table. + * + * @exception SQLException If an error occurs. + */ +public abstract void +setTypeMap(Map map) throws SQLException; + } // interface Connection diff --git a/libjava/java/sql/DataTruncation.java b/libjava/java/sql/DataTruncation.java index eabd46c..3449913 100644 --- a/libjava/java/sql/DataTruncation.java +++ b/libjava/java/sql/DataTruncation.java @@ -33,7 +33,7 @@ package java.sql; * * @author Aaron M. Renn (arenn@urbanophile.com) */ -public class DataTruncation extends SQLWarning implements java.io.Serializable +public class DataTruncation extends SQLWarning { /*************************************************************************/ @@ -72,6 +72,15 @@ private boolean read; */ private int transferSize; +/*************************************************************************/ + +/** + * Static Variables + */ + +/** + * This is the serialization UID for this class + */ private static final long serialVersionUID = 6464298989504059473L; /*************************************************************************/ diff --git a/libjava/java/sql/DatabaseMetaData.java b/libjava/java/sql/DatabaseMetaData.java index d0f4e1a..a643c81 100644 --- a/libjava/java/sql/DatabaseMetaData.java +++ b/libjava/java/sql/DatabaseMetaData.java @@ -2456,5 +2456,276 @@ public abstract ResultSet getIndexInfo(String catalog, String schema, String table, boolean unique, boolean approx) throws SQLException; +/*************************************************************************/ + +/** + * This method tests whether or not the datbase supports the specified + * result type. + * + * @param type The desired result type, which is one of the constants + * defined in <code>ResultSet</code>. + * + * @return <code>true</code> if the result set type is supported, + * <code>false</code> otherwise. + * + * @exception SQLException If an error occurs. + * + * @see ResultSet + */ +public abstract boolean +supportsResultSetType(int type) throws SQLException; + +/*************************************************************************/ + +/** + * This method tests whether the specified result set type and result set + * concurrency type are supported by the database. + * + * @param type The desired result type, which is one of the constants + * defined in <code>ResultSet</code>. + * @param concur The desired concurrency type, which is one of the constants + * defined in <code>ResultSet</code>. + * + * @return <code>true</code> if the result set type is supported, + * <code>false</code> otherwise. + * + * @exception SQLException If an error occurs. + * + * @see ResultSet + */ +public abstract boolean +supportsResultSetConcurrency(int type, int concur) throws SQLException; + +/*************************************************************************/ + +/** + * This method tests whether or not the specified result set type sees its + * own updates. + * + * @param type The desired result type, which is one of the constants + * defined in <code>ResultSet</code>. + * + * @return <code>true</code> if the result set type sees its own updates, + * <code>false</code> otherwise. + * + * @exception SQLException If an error occurs. + * + * @see ResultSet + */ +public abstract boolean +ownUpdatesAreVisible(int type) throws SQLException; + +/*************************************************************************/ + +/** + * This method tests whether or not the specified result set type sees its + * own deletes. + * + * @param type The desired result type, which is one of the constants + * defined in <code>ResultSet</code>. + * + * @return <code>true</code> if the result set type sees its own deletes, + * <code>false</code> otherwise. + * + * @exception SQLException If an error occurs. + * + * @see ResultSet + */ +public abstract boolean +ownDeletesAreVisible(int type) throws SQLException; + +/*************************************************************************/ + +/** + * This method tests whether or not the specified result set type sees its + * own inserts. + * + * @param type The desired result type, which is one of the constants + * defined in <code>ResultSet</code>. + * + * @return <code>true</code> if the result set type sees its own inserts, + * <code>false</code> otherwise. + * + * @exception SQLException If an error occurs. + * + * @see ResultSet + */ +public abstract boolean +ownInsertsAreVisible(int type) throws SQLException; + +/*************************************************************************/ + +/** + * This method tests whether or not the specified result set type sees + * updates committed by others. + * + * @param type The desired result type, which is one of the constants + * defined in <code>ResultSet</code>. + * + * @return <code>true</code> if the result set type sees other updates, + * <code>false</code> otherwise. + * + * @exception SQLException If an error occurs. + * + * @see ResultSet + */ +public abstract boolean +othersUpdatesAreVisible(int type) throws SQLException; + +/*************************************************************************/ + +/** + * This method tests whether or not the specified result set type sees + * deletes committed by others. + * + * @param type The desired result type, which is one of the constants + * defined in <code>ResultSet</code>. + * + * @return <code>true</code> if the result set type sees other deletes, + * <code>false</code> otherwise. + * + * @exception SQLException If an error occurs. + * + * @see ResultSet + */ +public abstract boolean +othersDeletesAreVisible(int type) throws SQLException; + +/*************************************************************************/ + +/** + * This method tests whether or not the specified result set type sees + * inserts committed by others. + * + * @param type The desired result type, which is one of the constants + * defined in <code>ResultSet</code>. + * + * @return <code>true</code> if the result set type sees other inserts, + * <code>false</code> otherwise. + * + * @exception SQLException If an error occurs. + * + * @see ResultSet + */ +public abstract boolean +othersInsertsAreVisible(int type) throws SQLException; + +/*************************************************************************/ + +/** + * This method tests whether or not the specified result set type can detect + * a visible update by calling the <code>rowUpdated</code> method. + * + * @param type The desired result type, which is one of the constants + * defined in <code>ResultSet</code>. + * + * @return <code>true</code> if the result set type can detect visible updates + * using <code>rowUpdated</code>, <code>false</code> otherwise. + * + * @exception SQLException If an error occurs. + * + * @see ResultSet + */ +public abstract boolean +updatesAreDetected(int type) throws SQLException; + +/*************************************************************************/ + +/** + * This method tests whether or not the specified result set type can detect + * a visible delete by calling the <code>rowUpdated</code> method. + * + * @param type The desired result type, which is one of the constants + * defined in <code>ResultSet</code>. + * + * @return <code>true</code> if the result set type can detect visible deletes + * using <code>rowUpdated</code>, <code>false</code> otherwise. + * + * @exception SQLException If an error occurs. + * + * @see ResultSet + */ +public abstract boolean +deletesAreDetected(int type) throws SQLException; + +/*************************************************************************/ + +/** + * This method tests whether or not the specified result set type can detect + * a visible insert by calling the <code>rowUpdated</code> method. + * + * @param type The desired result type, which is one of the constants + * defined in <code>ResultSet</code>. + * + * @return <code>true</code> if the result set type can detect visible inserts + * using <code>rowUpdated</code>, <code>false</code> otherwise. + * + * @exception SQLException If an error occurs. + * + * @see ResultSet + */ +public abstract boolean +insertsAreDetected(int type) throws SQLException; + +/*************************************************************************/ + +/** + * This method tests whether or not the database supports batch updates. + * + * @return <code>true</code> if batch updates are supported, + * <code>false</code> otherwise. + * + * @exception SQLException If an error occurs. + */ +public abstract boolean +supportsBatchUpdates() throws SQLException; + +/*************************************************************************/ + +/** + * This method returns the list of user defined data types in use. These + * are returned as a <code>ResultSet</code> with the following columns: + * <p> + * <ol> + * <li>TYPE_CAT - The catalog name, which may be <code>null</code>. + * <li>TYPE_SCEHM - The schema name, which may be <code>null</code>. + * <li>TYPE_NAME - The user defined data type name. + * <li>CLASS_NAME - The Java class name this type maps to. + * <li>DATA_TYPE - A type identifer from <code>Types</code> for this type. + * This will be one of <code>JAVA_OBJECT</code>, <code>STRUCT</code>, or + * <code>DISTINCT</code>. + * <li>REMARKS - Comments about this data type. + * </ol> + * + * @param catalog The catalog to retrieve information from, or the empty string + * to return entities not associated with a catalog, or <code>null</code> + * to return information from all catalogs. + * @param schema The schema to retrieve information from, or the empty string + * to return entities not associated with a schema. + * @param typePattern The type name pattern to match. + * @param types The type identifer patterns (from <code>Types</code>) to + * match. + * + * @return A <code>ResultSet</code> with the requested type information + * + * @exception SQLException If an error occurs. + */ +public abstract ResultSet +getUDTs(String catalog, String schema, String typePattern, int[] types) + throws SQLException; + +/*************************************************************************/ + +/** + * This method returns the <code>Connection</code> object that was used + * to generate the metadata in this object. + * + * @return The connection for this object. + * + * @exception SQLException If an error occurs. + */ +public abstract Connection +getConnection() throws SQLException; + } // interface DatabaseMetaData diff --git a/libjava/java/sql/DriverManager.java b/libjava/java/sql/DriverManager.java index 3612783..19d4e9d 100644 --- a/libjava/java/sql/DriverManager.java +++ b/libjava/java/sql/DriverManager.java @@ -1,5 +1,5 @@ /* DriverManager.java -- Manage JDBC drivers - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 2000 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -138,6 +138,38 @@ setLoginTimeout(int login_timeout) /*************************************************************************/ /** + * This method returns the log writer being used by all JDBC drivers. + * This method should be used in place of the deprecated + * <code>getLogStream</code> method. + * + * @return The log writer in use by JDBC drivers. + */ +public static PrintWriter +getLogWriter() +{ + return(log_writer); +} + +/*************************************************************************/ + +/** + * This method sets the log writer being used by JDBC drivers. This is a + * system-wide parameter that affects all drivers. Note that since there + * is no way to retrieve a <code>PrintStream</code> from a + * <code>PrintWriter</code>, this method cannot set the log stream in + * use by JDBC. Thus any older drivers may not see this setting. + * + * @param log_writer The new log writer for JDBC. + */ +public static void +setLogWriter(PrintWriter log_writer) +{ + DriverManager.log_writer = log_writer; +} + +/*************************************************************************/ + +/** * This method returns the log stream in use by JDBC. * * @return The log stream in use by JDBC. @@ -186,9 +218,11 @@ println(String str) * called by the driver itself in a static initializer. * * @param driver The new <code>Driver</code> to add. + * + * @exception SQLException If an error occurs. */ public static void -registerDriver(Driver driver) +registerDriver(Driver driver) throws SQLException { if (!drivers.contains(driver)) drivers.addElement(driver); @@ -200,9 +234,11 @@ registerDriver(Driver driver) * This method de-registers a driver from the manager. * * @param driver The <code>Driver</code> to unregister. + * + * @exception SQLException If an error occurs. */ public static void -deregisterDriver(Driver driver) +deregisterDriver(Driver driver) throws SQLException { if (drivers.contains(driver)) drivers.removeElement(driver); @@ -211,15 +247,30 @@ deregisterDriver(Driver driver) /*************************************************************************/ /** - * This method returns a list of all the currently loaded JDBC drivers which - * the current caller has access to. + * This method returns a list of all the currently registered JDBC drivers + * that were loaded by the current <code>ClassLoader</code>. * * @return An <code>Enumeration</code> of all currently loaded JDBC drivers. */ public static Enumeration getDrivers() { - return(drivers.elements()); + Vector v = new Vector(); + Enumeration e = drivers.elements(); + + // Is this right? + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + + while(e.hasMoreElements()) + { + Object obj = e.nextElement(); + if (!obj.getClass().getClassLoader().equals(cl)) + continue; + + v.addElement(obj); + } + + return(v.elements()); } /*************************************************************************/ diff --git a/libjava/java/sql/PreparedStatement.java b/libjava/java/sql/PreparedStatement.java index 870f5fc..dc8b1c4 100644 --- a/libjava/java/sql/PreparedStatement.java +++ b/libjava/java/sql/PreparedStatement.java @@ -30,6 +30,7 @@ package java.sql; import java.io.InputStream; import java.io.Reader; import java.math.BigDecimal; +import java.util.Calendar; /** * This interface provides a mechanism for executing pre-compiled @@ -57,6 +58,21 @@ setNull(int index, int type) throws SQLException; /*************************************************************************/ /** + * This method populates the specified parameter with a SQL NULL value + * for the specified type. + * + * @param index The index of the parameter to set. + * @param type The SQL type identifier of the parameter from <code>Types</code> + * @param name The name of the data type, for user defined types. + * + * @exception SQLException If an error occurs. + */ +public abstract void +setNull(int index, int type, String name) throws SQLException; + +/*************************************************************************/ + +/** * This method sets the specified parameter from the given Java * <code>boolean</code> value. * @@ -212,6 +228,21 @@ setDate(int index, java.sql.Date value) throws SQLException; /** * This method sets the specified parameter from the given Java + * <code>java.sql.Date</code> value. + * + * @param index The index of the parameter value to set. + * @param value The value of the parameter. + * @param calendar The <code>Calendar</code> to use for timezone and locale. + * + * @exception SQLException If an error occurs. + */ +public abstract void +setDate(int index, java.sql.Date value, Calendar calendar) throws SQLException; + +/*************************************************************************/ + +/** + * This method sets the specified parameter from the given Java * <code>java.sql.Time</code> value. * * @param index The index of the parameter value to set. @@ -226,6 +257,21 @@ setTime(int index, java.sql.Time value) throws SQLException; /** * This method sets the specified parameter from the given Java + * <code>java.sql.Time</code> value. + * + * @param index The index of the parameter value to set. + * @param value The value of the parameter. + * @param calendar The <code>Calendar</code> to use for timezone and locale. + * + * @exception SQLException If an error occurs. + */ +public abstract void +setTime(int index, java.sql.Time value, Calendar calendar) throws SQLException; + +/*************************************************************************/ + +/** + * This method sets the specified parameter from the given Java * <code>java.sql.Timestamp</code> value. * * @param index The index of the parameter value to set. @@ -240,6 +286,22 @@ setTimestamp(int index, java.sql.Timestamp value) throws SQLException; /** * This method sets the specified parameter from the given Java + * <code>java.sql.Timestamp</code> value. + * + * @param index The index of the parameter value to set. + * @param value The value of the parameter. + * @param calendar The <code>Calendar</code> to use for timezone and locale. + * + * @exception SQLException If an error occurs. + */ +public abstract void +setTimestamp(int index, java.sql.Timestamp value, Calendar calendar) + throws SQLException; + +/*************************************************************************/ + +/** + * This method sets the specified parameter from the given Java * ASCII <code>InputStream</code> value. * * @param index The index of the parameter value to set. @@ -285,6 +347,81 @@ setBinaryStream(int index, InputStream value, int length) throws SQLException; /** * This method sets the specified parameter from the given Java + * character <code>Reader</code> value. + * + * @param index The index of the parameter value to set. + * @param value The value of the parameter. + * @param length The number of bytes in the stream. + * + * @exception SQLException If an error occurs. + */ +public abstract void +setCharacterStream(int index, Reader value, int length) throws SQLException; + +/*************************************************************************/ + +/** + * This method sets the specified parameter from the given Java + * <code>Ref</code> value. The default object type to SQL type mapping + * will be used. + * + * @param index The index of the parameter value to set. + * @param value The value of the parameter. + * + * @exception SQLException If an error occurs. + */ +public abstract void +setRef(int index, Ref value) throws SQLException; + +/*************************************************************************/ + +/** + * This method sets the specified parameter from the given Java + * <code>Blob</code> value. The default object type to SQL type mapping + * will be used. + * + * @param index The index of the parameter value to set. + * @param value The value of the parameter. + * + * @exception SQLException If an error occurs. + */ +public abstract void +setBlob(int index, Blob value) throws SQLException; + +/*************************************************************************/ + +/** + * This method sets the specified parameter from the given Java + * <code>Clob</code> value. The default object type to SQL type mapping + * will be used. + * + * @param index The index of the parameter value to set. + * @param value The value of the parameter. + * + * @exception SQLException If an error occurs. + */ +public abstract void +setClob(int index, Clob value) throws SQLException; + +/*************************************************************************/ + +/** + * This method sets the specified parameter from the given Java + * <code>Array</code> value. The default object type to SQL type mapping + * will be used. + * + * @param index The index of the parameter value to set. + * @param value The value of the parameter. + * + * @exception SQLException If an error occurs. + */ +public abstract void +setArray(int index, Array value) throws SQLException; + +/*************************************************************************/ + +/** + * This method sets the specified parameter from the given Java * <code>Object</code> value. The default object type to SQL type mapping * will be used. * @@ -334,6 +471,16 @@ setObject(int index, Object value, int type, int scale) throws SQLException; /*************************************************************************/ /** + * This method adds a set of parameters to the batch for JDBC 2.0. + * + * @exception SQLException If an error occurs. + */ +public abstract void +addBatch() throws SQLException; + +/*************************************************************************/ + +/** * This method clears all of the input parameter that have been * set on this statement. * @@ -345,6 +492,18 @@ clearParameters() throws SQLException; /*************************************************************************/ /** + * This method returns meta data for the result set from this statement. + * + * @return Meta data for the result set from this statement. + * + * @exception SQLException If an error occurs. + */ +public abstract ResultSetMetaData +getMetaData() throws SQLException; + +/*************************************************************************/ + +/** * This method executes a prepared SQL query. * Some prepared statements return multiple results; the execute method * handles these complex statements as well as the simpler form of diff --git a/libjava/java/sql/Ref.java b/libjava/java/sql/Ref.java new file mode 100644 index 0000000..2aaecfc --- /dev/null +++ b/libjava/java/sql/Ref.java @@ -0,0 +1,51 @@ +/* Ref.java -- Reference to a SQL structured type. + Copyright (C) 1999, 2000 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ + + +package java.sql; + +/** + * This interface provides a mechanism for obtaining information about + * a SQL structured type + * + * @author Aaron M. Renn (arenn@urbanophile.com) + */ +public interface Ref +{ + +/** + * This method returns the fully qualified name of the SQL structured + * type of the referenced item. + * + * @return The fully qualified name of the SQL structured type. + * + * @exception SQLException If an error occurs. + */ +public abstract String +getBaseTypeName() throws SQLException; + +} // interface Ref + diff --git a/libjava/java/sql/ResultSet.java b/libjava/java/sql/ResultSet.java index d9215ad5..536254f 100644 --- a/libjava/java/sql/ResultSet.java +++ b/libjava/java/sql/ResultSet.java @@ -1,5 +1,5 @@ /* ResultSet.java -- A SQL statement result set. - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 2000 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -30,6 +30,8 @@ package java.sql; import java.io.InputStream; import java.io.Reader; import java.math.BigDecimal; +import java.util.Calendar; +import java.util.Map; /** * This interface provides access to the data set returned by a SQL @@ -49,6 +51,50 @@ public interface ResultSet { /** + * The rows will be processed in order from first to last. + */ +public static final int FETCH_FORWARD = 0; + +/** + * The rows will be processed in order from last to first. + */ +public static final int FETCH_REVERSE = 1; + +/** + * The rows will be processed in an unknown order + */ +public static final int FETCH_UNKNOWN = 2; + +/** + * This type of result set may only step forward through the rows returned. + */ +public static final int TYPE_FORWARD_ONLY = 0; + +/** + * This type of result set is scrollable and is not sensitive to changes + * made by other statements. + */ +public static final int TYPE_SCROLL_INSENSITIVE = 1; + +/** + * This type of result set is scrollable and is also sensitive to changes + * made by other statements. + */ +public static final int TYPE_SCROLL_SENSITIVE = 1; + +/** + * The concurrency mode of for the result set may not be modified. + */ +public static final int CONCUR_READ_ONLY = 0; + +/** + * The concurrency mode of for the result set may be modified. + */ +public static final int CONCUR_UPDATABLE = 1; + +/*************************************************************************/ + +/** * This method advances to the next row in the result set. Any streams * open on the current row are closed automatically. * @@ -63,6 +109,20 @@ next() throws SQLException; /*************************************************************************/ /** + * This method moves the current position to the previous row in the + * result set. + * + * @return <code>true</code> if the previous row exists, <code>false</code> + * otherwise. + * + * @exception SQLException If an error occurs. + */ +public abstract boolean +previous() throws SQLException; + +/*************************************************************************/ + +/** * This method closes the result set and frees any associated resources. * * @exception SQLException If an error occurs. @@ -226,6 +286,21 @@ getDouble(int index) throws SQLException; * <code>BigDecimal</code>. * * @param index The index of the column to return. + * + * @return The column value as a <code>BigDecimal</code>. + * + * @exception SQLException If an error occurs. + */ +public abstract BigDecimal +getBigDecimal(int index) throws SQLException; + +/*************************************************************************/ + +/** + * This method returns the value of the specified column as a Java + * <code>BigDecimal</code>. + * + * @param index The index of the column to return. * @param scale The number of digits to the right of the decimal to return. * * @return The column value as a <code>BigDecimal</code>. @@ -352,6 +427,24 @@ getBinaryStream(int index) throws SQLException; /*************************************************************************/ /** + * This method returns the value of the specified column as a character + * stream. Note that all the data from this stream must be read before + * fetching the value of any other column. Please also be aware that + * calling <code>next()</code> or <code>close()</code> on this result set + * will close this stream as well. + * + * @param index The index of the column to return. + * + * @return The column value as an character <code>Reader</code>. + * + * @exception SQLException If an error occurs. + */ +public abstract Reader +getCharacterStream(int index) throws SQLException; + +/*************************************************************************/ + +/** * This method returns the value of the specified column as a Java * <code>String</code>. * @@ -491,6 +584,21 @@ getDouble(String column) throws SQLException; * <code>BigDecimal</code>. * * @param column The name of the column to return. + * + * @return The column value as a <code>BigDecimal</code>. + * + * @exception SQLException If an error occurs. + */ +public abstract BigDecimal +getBigDecimal(String column) throws SQLException; + +/*************************************************************************/ + +/** + * This method returns the value of the specified column as a Java + * <code>BigDecimal</code>. + * + * @param column The name of the column to return. * @param scale The number of digits to the right of the decimal to return. * * @return The column value as a <code>BigDecimal</code>. @@ -617,6 +725,24 @@ getBinaryStream(String column) throws SQLException; /*************************************************************************/ /** + * This method returns the value of the specified column as a character + * stream. Note that all the data from this stream must be read before + * fetching the value of any other column. Please also be aware that + * calling <code>next()</code> or <code>close()</code> on this result set + * will close this stream as well. + * + * @param column The name of the column to return. + * + * @return The column value as an character <code>Reader</code>. + * + * @exception SQLException If an error occurs. + */ +public abstract Reader +getCharacterStream(String column) throws SQLException; + +/*************************************************************************/ + +/** * This method returns the first SQL warning associated with this result * set. Any additional warnings will be chained to this one. * @@ -678,5 +804,1203 @@ getMetaData() throws SQLException; public abstract int findColumn(String column) throws SQLException; +/*************************************************************************/ + +/** + * This method tests whether or not the cursor is before the first row + * in the result set. + * + * @return <code>true</code> if the cursor is positioned before the first + * row, <code>false</code> otherwise. + * + * @exception SQLException If an error occurs. + */ +public abstract boolean +isBeforeFirst() throws SQLException; + +/*************************************************************************/ + +/** + * This method tests whether or not the cursor is after the last row + * in the result set. + * + * @return <code>true</code> if the cursor is positioned after the last + * row, <code>false</code> otherwise. + * + * @exception SQLException If an error occurs. + */ +public abstract boolean +isAfterLast() throws SQLException; + +/*************************************************************************/ + +/** + * This method tests whether or not the cursor is positioned on the first + * row in the result set. + * + * @return <code>true</code> if the cursor is positioned on the first + * row, <code>false</code> otherwise. + * + * @exception SQLException If an error occurs. + */ +public abstract boolean +isFirst() throws SQLException; + +/*************************************************************************/ + +/** + * This method tests whether or not the cursor is on the last row + * in the result set. + * + * @return <code>true</code> if the cursor is positioned on the last + * row, <code>false</code> otherwise. + * + * @exception SQLException If an error occurs. + */ +public abstract boolean +isLast() throws SQLException; + +/*************************************************************************/ + +/** + * This method repositions the cursor to before the first row in the + * result set. + * + * @exception SQLException If an error occurs. + */ +public abstract void +beforeFirst() throws SQLException; + +/*************************************************************************/ + +/** + * This method repositions the cursor to after the last row in the result + * set. + * + * @exception SQLException If an error occurs. + */ +public abstract void +afterLast() throws SQLException; + +/*************************************************************************/ + +/** + * This method repositions the cursor on the first row in the + * result set. + * + * @return <code>true</code> if the cursor is on a valid row; + * <code>false</code> if there are no rows in the result set. + * + * @exception SQLException If an error occurs. + */ +public abstract boolean +first() throws SQLException; + +/*************************************************************************/ + +/** + * This method repositions the cursor on the last row in the result + * set. + * + * @return <code>true</code> if the cursor is on a valid row; + * <code>false</code> if there are no rows in the result set. + * + * @exception SQLException If an error occurs. + */ +public abstract boolean +last() throws SQLException; + +/*************************************************************************/ + +/** + * This method returns the current row number in the cursor. Numbering + * begins at index 1. + * + * @return The current row number, or 0 if there is not current row. + * + * @exception SQLException If an error occurs. + */ +public abstract int +getRow() throws SQLException; + +/*************************************************************************/ + +/** + * This method positions the result set to the specified absolute row. + * Positive numbers are row offsets from the beginning of the result + * set (numbering starts from row 1) and negative numbers are row offsets + * from the end of the result set (numbering starts from -1). + * + * @param row The row to position the result set to. + * + * @return <code>true</code> if the current position was changed, + * <code>false</code> otherwise. + * + * @exception SQLException If an error occurs. + */ +public abstract boolean +absolute(int row) throws SQLException; + +/*************************************************************************/ + +/** + * This method moves the result set position relative to the current row. + * The offset can be positive or negative. + * + * @param row The relative row position to move to. + * + * @return <code>true</code> if the current position was changed, + * <code>false</code> otherwise. + * + * @exception SQLException If an error occurs. + */ +public abstract boolean +relative(int row) throws SQLException; + +/*************************************************************************/ + +/** + * This method provides a hint to the driver about which direction the + * result set will be processed in. + * + * @param direction The direction in which rows will be processed. (Values?) + * + * @exception SQLException If an error occurs. + */ +public abstract void +setFetchDirection(int direction) throws SQLException; + +/*************************************************************************/ + +/** + * This method returns the current fetch direction for this result set. + * + * @return The fetch direction for this result set. + * + * @exception SQLException If an error occurs. + */ +public abstract int +getFetchDirection() throws SQLException; + +/*************************************************************************/ + +/** + * This method provides a hint to the driver about how many rows at a + * time it should fetch from the database. + * + * @param rows The number of rows the driver should fetch per call. + * + * @exception SQLException If an error occurs. + */ +public abstract void +setFetchSize(int rows) throws SQLException; + +/*************************************************************************/ + +/** + * This method returns the current number of rows that will be fetched + * from the database at a time. + * + * @return The current fetch size for this result set. + * + * @exception SQLException If an error occurs. + */ +public abstract int +getFetchSize() throws SQLException; + +/*************************************************************************/ + +/** + * This method returns the result set type of this result set. This will + * be one of the TYPE_* constants defined in this interface. + * + * @return The result set type. + * + * @exception SQLException If an error occurs. + */ +public abstract int +getType() throws SQLException; + +/*************************************************************************/ + +/** + * This method returns the concurrency type of this result set. This will + * be one of the CONCUR_* constants defined in this interface. + * + * @return The result set concurrency type. + * + * @exception SQLException If an error occurs. + */ +public abstract int +getConcurrency() throws SQLException; + +/*************************************************************************/ + +/** + * This method tests whether or not the current row in the result set + * has been updated. Updates must be visible in order of this method to + * detect the update. + * + * @return <code>true</code> if the row has been updated, <code>false</code> + * otherwise. + * + * @exception SQLException If an error occurs. + */ +public abstract boolean +rowUpdated() throws SQLException; + +/*************************************************************************/ + +/** + * This method tests whether or not the current row in the result set + * has been inserted. Inserts must be visible in order of this method to + * detect the insert. + * + * @return <code>true</code> if the row has been inserted, <code>false</code> + * otherwise. + * + * @exception SQLException If an error occurs. + */ +public abstract boolean +rowInserted() throws SQLException; + +/*************************************************************************/ + +/** + * This method tests whether or not the current row in the result set + * has been deleted. Deletes must be visible in order of this method to + * detect the deletion. + * + * @return <code>true</code> if the row has been deleted, <code>false</code> + * otherwise. + * + * @exception SQLException If an error occurs. + */ +public abstract boolean +rowDeleted() throws SQLException; + +/*************************************************************************/ + +/** + * This method updates the specified column to have a NULL value. This + * does not update the actual database. <code>updateRow</code> must be + * called in order to do that. + * + * @return index The index of the column to update. + * + * @exception SQLException If an error occurs. + */ +public abstract void +updateNull(int index) throws SQLException; + +/*************************************************************************/ + +/** + * This method updates the specified column to have a boolean value. This + * does not update the actual database. <code>updateRow</code> must be + * called in order to do that. + * + * @param index The index of the column to update. + * @param value The new value of the column. + * + * @exception SQLException If an error occurs. + */ +public abstract void +updateBoolean(int index, boolean value) throws SQLException; + +/*************************************************************************/ + +/** + * This method updates the specified column to have a byte value. This + * does not update the actual database. <code>updateRow</code> must be + * called in order to do that. + * + * @param index The index of the column to update. + * @param value The new value of the column. + * + * @exception SQLException If an error occurs. + */ +public abstract void +updateByte(int index, byte value) throws SQLException; + +/*************************************************************************/ + +/** + * This method updates the specified column to have a short value. This + * does not update the actual database. <code>updateRow</code> must be + * called in order to do that. + * + * @param index The index of the column to update. + * @param value The new value of the column. + * + * @exception SQLException If an error occurs. + */ +public abstract void +updateShort(int index, short value) throws SQLException; + +/*************************************************************************/ + +/** + * This method updates the specified column to have an int value. This + * does not update the actual database. <code>updateRow</code> must be + * called in order to do that. + * + * @param index The index of the column to update. + * @param value The new value of the column. + * + * @exception SQLException If an error occurs. + */ +public abstract void +updateInt(int index, int value) throws SQLException; + +/*************************************************************************/ + +/** + * This method updates the specified column to have a long value. This + * does not update the actual database. <code>updateRow</code> must be + * called in order to do that. + * + * @param index The index of the column to update. + * @param value The new value of the column. + * + * @exception SQLException If an error occurs. + */ +public abstract void +updateLong(int index, long value) throws SQLException; + +/*************************************************************************/ + +/** + * This method updates the specified column to have a float value. This + * does not update the actual database. <code>updateRow</code> must be + * called in order to do that. + * + * @param index The index of the column to update. + * @param value The new value of the column. + * + * @exception SQLException If an error occurs. + */ +public abstract void +updateFloat(int index, float value) throws SQLException; + +/*************************************************************************/ + +/** + * This method updates the specified column to have a double value. This + * does not update the actual database. <code>updateRow</code> must be + * called in order to do that. + * + * @param index The index of the column to update. + * @param value The new value of the column. + * + * @exception SQLException If an error occurs. + */ +public abstract void +updateDouble(int index, double value) throws SQLException; + +/*************************************************************************/ + +/** + * This method updates the specified column to have a BigDecimal value. This + * does not update the actual database. <code>updateRow</code> must be + * called in order to do that. + * + * @param index The index of the column to update. + * @param value The new value of the column. + * + * @exception SQLException If an error occurs. + */ +public abstract void +updateBigDecimal(int index, BigDecimal value) throws SQLException; + +/*************************************************************************/ + +/** + * This method updates the specified column to have a String value. This + * does not update the actual database. <code>updateRow</code> must be + * called in order to do that. + * + * @param index The index of the column to update. + * @param value The new value of the column. + * + * @exception SQLException If an error occurs. + */ +public abstract void +updateString(int index, String value) throws SQLException; + +/*************************************************************************/ + +/** + * This method updates the specified column to have a byte array value. This + * does not update the actual database. <code>updateRow</code> must be + * called in order to do that. + * + * @param index The index of the column to update. + * @param value The new value of the column. + * + * @exception SQLException If an error occurs. + */ +public abstract void +updateBytes(int index, byte[] value) throws SQLException; + +/*************************************************************************/ + +/** + * This method updates the specified column to have a java.sql.Date value. This + * does not update the actual database. <code>updateRow</code> must be + * called in order to do that. + * + * @param index The index of the column to update. + * @param value The new value of the column. + * + * @exception SQLException If an error occurs. + */ +public abstract void +updateDate(int index, java.sql.Date value) throws SQLException; + +/*************************************************************************/ + +/** + * This method updates the specified column to have a java.sql.Time value. This + * does not update the actual database. <code>updateRow</code> must be + * called in order to do that. + * + * @param index The index of the column to update. + * @param value The new value of the column. + * + * @exception SQLException If an error occurs. + */ +public abstract void +updateTime(int index, java.sql.Time value) throws SQLException; + +/*************************************************************************/ + +/** + * This method updates the specified column to have a java.sql.Timestamp value. + * This does not update the actual database. <code>updateRow</code> must be + * called in order to do that. + * + * @param index The index of the column to update. + * @param value The new value of the column. + * + * @exception SQLException If an error occurs. + */ +public abstract void +updateTimestamp(int index, java.sql.Timestamp value) throws SQLException; + +/*************************************************************************/ + +/** + * This method updates the specified column from an ASCII text stream. + * This does not update the actual database. <code>updateRow</code> must be + * called in order to do that. + * + * @param index The index of the column to update. + * @param value The new value of the column. + * @param length The length of the stream. + * + * @exception SQLException If an error occurs. + */ +public abstract void +updateAsciiStream(int index, InputStream value, int length) throws SQLException; + +/*************************************************************************/ + +/** + * This method updates the specified column from a binary stream. + * This does not update the actual database. <code>updateRow</code> must be + * called in order to do that. + * + * @param index The index of the column to update. + * @param value The new value of the column. + * @param length The length of the stream. + * + * @exception SQLException If an error occurs. + */ +public abstract void +updateBinaryStream(int index, InputStream value, int length) + throws SQLException; + +/*************************************************************************/ + +/** + * This method updates the specified column from a character stream. + * This does not update the actual database. <code>updateRow</code> must be + * called in order to do that. + * + * @param index The index of the column to update. + * @param value The new value of the column. + * @param length The length of the stream. + * + * @exception SQLException If an error occurs. + */ +public abstract void +updateCharacterStream(int index, Reader value, int length) throws SQLException; + +/*************************************************************************/ + +/** + * This method updates the specified column to have an Object value. + * This does not update the actual database. <code>updateRow</code> must be + * called in order to do that. + * + * @param index The index of the column to update. + * @param value The new value of the column. + * + * @exception SQLException If an error occurs. + */ +public abstract void +updateObject(int index, Object value) throws SQLException; + +/*************************************************************************/ + +/** + * This method updates the specified column to have an Object value. + * This does not update the actual database. <code>updateRow</code> must be + * called in order to do that. + * + * @param index The index of the column to update. + * @param value The new value of the column. + * @param scale The scale of the object in question, which is used only + * for numeric type objects. + * + * @exception SQLException If an error occurs. + */ +public abstract void +updateObject(int index, Object value, int scale) throws SQLException; + +/*************************************************************************/ + +/** + * This method updates the specified column to have a NULL value. This + * does not update the actual database. <code>updateRow</code> must be + * called in order to do that. + * + * @return name The name of the column to update. + * + * @exception SQLException If an error occurs. + */ +public abstract void +updateNull(String name) throws SQLException; + +/*************************************************************************/ + +/** + * This method updates the specified column to have a boolean value. This + * does not update the actual database. <code>updateRow</code> must be + * called in order to do that. + * + * @param name The name of the column to update. + * @param value The new value of the column. + * + * @exception SQLException If an error occurs. + */ +public abstract void +updateBoolean(String name, boolean value) throws SQLException; + +/*************************************************************************/ + +/** + * This method updates the specified column to have a byte value. This + * does not update the actual database. <code>updateRow</code> must be + * called in order to do that. + * + * @param name The name of the column to update. + * @param value The new value of the column. + * + * @exception SQLException If an error occurs. + */ +public abstract void +updateByte(String name, byte value) throws SQLException; + +/*************************************************************************/ + +/** + * This method updates the specified column to have a short value. This + * does not update the actual database. <code>updateRow</code> must be + * called in order to do that. + * + * @param name The name of the column to update. + * @param value The new value of the column. + * + * @exception SQLException If an error occurs. + */ +public abstract void +updateShort(String name, short value) throws SQLException; + +/*************************************************************************/ + +/** + * This method updates the specified column to have an int value. This + * does not update the actual database. <code>updateRow</code> must be + * called in order to do that. + * + * @param name The name of the column to update. + * @param value The new value of the column. + * + * @exception SQLException If an error occurs. + */ +public abstract void +updateInt(String name, int value) throws SQLException; + +/*************************************************************************/ + +/** + * This method updates the specified column to have a long value. This + * does not update the actual database. <code>updateRow</code> must be + * called in order to do that. + * + * @param name The name of the column to update. + * @param value The new value of the column. + * + * @exception SQLException If an error occurs. + */ +public abstract void +updateLong(String name, long value) throws SQLException; + +/*************************************************************************/ + +/** + * This method updates the specified column to have a float value. This + * does not update the actual database. <code>updateRow</code> must be + * called in order to do that. + * + * @param name The name of the column to update. + * @param value The new value of the column. + * + * @exception SQLException If an error occurs. + */ +public abstract void +updateFloat(String name, float value) throws SQLException; + +/*************************************************************************/ + +/** + * This method updates the specified column to have a double value. This + * does not update the actual database. <code>updateRow</code> must be + * called in order to do that. + * + * @param name The name of the column to update. + * @param value The new value of the column. + * + * @exception SQLException If an error occurs. + */ +public abstract void +updateDouble(String name, double value) throws SQLException; + +/*************************************************************************/ + +/** + * This method updates the specified column to have a BigDecimal value. This + * does not update the actual database. <code>updateRow</code> must be + * called in order to do that. + * + * @param name The name of the column to update. + * @param value The new value of the column. + * + * @exception SQLException If an error occurs. + */ +public abstract void +updateBigDecimal(String name, BigDecimal value) throws SQLException; + +/*************************************************************************/ + +/** + * This method updates the specified column to have a String value. This + * does not update the actual database. <code>updateRow</code> must be + * called in order to do that. + * + * @param name The name of the column to update. + * @param value The new value of the column. + * + * @exception SQLException If an error occurs. + */ +public abstract void +updateString(String name, String value) throws SQLException; + +/*************************************************************************/ + +/** + * This method updates the specified column to have a byte array value. This + * does not update the actual database. <code>updateRow</code> must be + * called in order to do that. + * + * @param name The name of the column to update. + * @param value The new value of the column. + * + * @exception SQLException If an error occurs. + */ +public abstract void +updateBytes(String name, byte[] value) throws SQLException; + +/*************************************************************************/ + +/** + * This method updates the specified column to have a java.sql.Date value. This + * does not update the actual database. <code>updateRow</code> must be + * called in order to do that. + * + * @param name The name of the column to update. + * @param value The new value of the column. + * + * @exception SQLException If an error occurs. + */ +public abstract void +updateDate(String name, java.sql.Date value) throws SQLException; + +/*************************************************************************/ + +/** + * This method updates the specified column to have a java.sql.Time value. This + * does not update the actual database. <code>updateRow</code> must be + * called in order to do that. + * + * @param name The name of the column to update. + * @param value The new value of the column. + * + * @exception SQLException If an error occurs. + */ +public abstract void +updateTime(String name, java.sql.Time value) throws SQLException; + +/*************************************************************************/ + +/** + * This method updates the specified column to have a java.sql.Timestamp value. + * This does not update the actual database. <code>updateRow</code> must be + * called in order to do that. + * + * @param name The name of the column to update. + * @param value The new value of the column. + * + * @exception SQLException If an error occurs. + */ +public abstract void +updateTimestamp(String name, java.sql.Timestamp value) throws SQLException; + +/*************************************************************************/ + +/** + * This method updates the specified column from an ASCII text stream. + * This does not update the actual database. <code>updateRow</code> must be + * called in order to do that. + * + * @param name The name of the column to update. + * @param value The new value of the column. + * @param length The length of the stream. + * + * @exception SQLException If an error occurs. + */ +public abstract void +updateAsciiStream(String name, InputStream value, int length) throws SQLException; + +/*************************************************************************/ + +/** + * This method updates the specified column from a binary stream. + * This does not update the actual database. <code>updateRow</code> must be + * called in order to do that. + * + * @param name The name of the column to update. + * @param value The new value of the column. + * @param length The length of the stream. + * + * @exception SQLException If an error occurs. + */ +public abstract void +updateBinaryStream(String name, InputStream value, int length) + throws SQLException; + +/*************************************************************************/ + +/** + * This method updates the specified column from a character stream. + * This does not update the actual database. <code>updateRow</code> must be + * called in order to do that. + * + * @param name The name of the column to update. + * @param value The new value of the column. + * @param length The length of the stream. + * + * @exception SQLException If an error occurs. + */ +public abstract void +updateCharacterStream(String name, Reader value, int length) throws SQLException; + +/*************************************************************************/ + +/** + * This method updates the specified column to have an Object value. + * This does not update the actual database. <code>updateRow</code> must be + * called in order to do that. + * + * @param name The name of the column to update. + * @param value The new value of the column. + * + * @exception SQLException If an error occurs. + */ +public abstract void +updateObject(String name, Object value) throws SQLException; + +/*************************************************************************/ + +/** + * This method updates the specified column to have an Object value. + * This does not update the actual database. <code>updateRow</code> must be + * called in order to do that. + * + * @param name The name of the column to update. + * @param value The new value of the column. + * @param scale The scale of the object in question, which is used only + * for numeric type objects. + * + * @exception SQLException If an error occurs. + */ +public abstract void +updateObject(String name, Object value, int scale) throws SQLException; + +/*************************************************************************/ + +/** + * This method inserts the current row into the database. The result set + * must be positioned on the insert row in order to call this method + * successfully. + * + * @exception SQLException If an error occurs. + */ +public abstract void +insertRow() throws SQLException; + +/*************************************************************************/ + +/** + * This method updates the current row in the database. + * + * @exception SQLException If an error occurs. + */ +public abstract void +updateRow() throws SQLException; + +/*************************************************************************/ + +/** + * This method deletes the current row in the database. + * + * @exception SQLException If an error occurs. + */ +public abstract void +deleteRow() throws SQLException; + +/*************************************************************************/ + +/** + * This method refreshes the contents of the current row from the database. + * + * @exception SQLException If an error occurs. + */ +public abstract void +refreshRow() throws SQLException; + +/*************************************************************************/ + +/** + * This method cancels any changes that have been made to a row. If + * the <code>rowUpdate</code> method has been called, then the changes + * cannot be undone. + * + * @exception SQLException If an error occurs. + */ +public abstract void +cancelRowUpdates() throws SQLException; + +/*************************************************************************/ + +/** + * This method positions the result set to the "insert row", which allows + * a new row to be inserted into the database from the result set. + * + * @exception SQLException If an error occurs. + */ +public abstract void +moveToInsertRow() throws SQLException; + +/*************************************************************************/ + +/** + * This method moves the result set position from the insert row back to + * the current row that was selected prior to moving to the insert row. + * + * @exception SQLException If an error occurs. + */ +public abstract void +moveToCurrentRow() throws SQLException; + +/*************************************************************************/ + +/** + * This method returns a the <code>Statement</code> that was used to + * produce this result set. + * + * @return The <code>Statement</code> used to produce this result set. + * + * @exception SQLException If an error occurs. + */ +public abstract Statement +getStatement() throws SQLException; + +/*************************************************************************/ + +/** + * This method returns the value of the specified column as a Java + * <code>Object</code> using the specified SQL type to Java type map. + * + * @param index The index of the column to return. + * @param map The SQL type to Java type map to use. + * + * @return The value of the column as an <code>Object</code>. + * + * @exception SQLException If an error occurs. + */ +public abstract Object +getObject(int index, Map map) throws SQLException; + +/*************************************************************************/ + +/** + * This method returns a <code>Ref</code> for the specified column which + * represents the structured type for the column. + * + * @param index The index of the column to return. + * + * @return A <code>Ref</code> object for the column + * + * @exception SQLException If an error occurs. + */ +public Ref +getRef(int index) throws SQLException; + +/*************************************************************************/ + +/** + * This method returns the specified column value as a BLOB. + * + * @param index The index of the column value to return. + * + * @return The value of the column as a BLOB. + * + * @exception SQLException If an error occurs. + */ +public abstract Blob +getBlob(int index) throws SQLException; + +/*************************************************************************/ + +/** + * This method returns the specified column value as a CLOB. + * + * @param index The index of the column value to return. + * + * @return The value of the column as a CLOB. + * + * @exception SQLException If an error occurs. + */ +public abstract Clob +getClob(int index) throws SQLException; + +/*************************************************************************/ + +/** + * This method returns the specified column value as an <code>Array</code>. + * + * @param index The index of the column value to return. + * + * @return The value of the column as an <code>Array</code>. + * + * @exception SQLException If an error occurs. + */ +public abstract Array +getArray(int index) throws SQLException; + +/*************************************************************************/ + +/** + * This method returns the value of the specified column as a Java + * <code>Object</code> using the specified SQL type to Java type map. + * + * @param name The name of the column to return. + * @param map The SQL type to Java type map to use. + * + * @return The value of the column as an <code>Object</code>. + * + * @exception SQLException If an error occurs. + */ +public abstract Object +getObject(String name, Map map) throws SQLException; + +/*************************************************************************/ + +/** + * This method returns a <code>Ref</code> for the specified column which + * represents the structured type for the column. + * + * @param index The index of the column to return. + * + * @return A <code>Ref</code> object for the column + * + * @exception SQLException If an error occurs. + */ +public Ref +getRef(String name) throws SQLException; + +/*************************************************************************/ + +/** + * This method returns the specified column value as a BLOB. + * + * @param name The name of the column value to return. + * + * @return The value of the column as a BLOB. + * + * @exception SQLException If an error occurs. + */ +public abstract Blob +getBlob(String name) throws SQLException; + +/*************************************************************************/ + +/** + * This method returns the specified column value as a CLOB. + * + * @param name The name of the column value to return. + * + * @return The value of the column as a CLOB. + * + * @exception SQLException If an error occurs. + */ +public abstract Clob +getClob(String name) throws SQLException; + +/*************************************************************************/ + +/** + * This method returns the specified column value as an <code>Array</code>. + * + * @param name The name of the column value to return. + * + * @return The value of the column as an <code>Array</code>. + * + * @exception SQLException If an error occurs. + */ +public abstract Array +getArray(String name) throws SQLException; + +/*************************************************************************/ + +/** + * This method returns the specified column value as a + * <code>java.sql.Date</code>. The specified <code>Calendar</code> is used + * to generate a value for the date if the database does not support + * timezones. + * + * @param index The index of the column value to return. + * @param cal The <code>Calendar</code> to use for calculating timezones. + * + * @return The value of the column as a <code>java.sql.Date</code>. + * + * @exception SQLException If an error occurs. + */ +public abstract java.sql.Date +getDate(int index, Calendar cal) throws SQLException; + +/*************************************************************************/ + +/** + * This method returns the specified column value as a + * <code>java.sql.Time</code>. The specified <code>Calendar</code> is used + * to generate a value for the time if the database does not support + * timezones. + * + * @param index The index of the column value to return. + * @param cal The <code>Calendar</code> to use for calculating timezones. + * + * @return The value of the column as a <code>java.sql.Time</code>. + * + * @exception SQLException If an error occurs. + */ +public abstract java.sql.Time +getTime(int index, Calendar cal) throws SQLException; + +/*************************************************************************/ + +/** + * This method returns the specified column value as a + * <code>java.sql.Timestamp</code>. The specified <code>Calendar</code> is used + * to generate a value for the timestamp if the database does not support + * timezones. + * + * @param index The index of the column value to return. + * @param cal The <code>Calendar</code> to use for calculating timezones. + * + * @return The value of the column as a <code>java.sql.Timestamp</code>. + * + * @exception SQLException If an error occurs. + */ +public abstract java.sql.Timestamp +getTimestamp(int index, Calendar cal) throws SQLException; + +/*************************************************************************/ + +/** + * This method returns the specified column value as a + * <code>java.sql.Date</code>. The specified <code>Calendar</code> is used + * to generate a value for the date if the database does not support + * timezones. + * + * @param name The name of the column value to return. + * @param cal The <code>Calendar</code> to use for calculating timezones. + * + * @return The value of the column as a <code>java.sql.Date</code>. + * + * @exception SQLException If an error occurs. + */ +public abstract java.sql.Date +getDate(String name, Calendar cal) throws SQLException; + +/*************************************************************************/ + +/** + * This method returns the specified column value as a + * <code>java.sql.Time</code>. The specified <code>Calendar</code> is used + * to generate a value for the time if the database does not support + * timezones. + * + * @param name The name of the column value to return. + * @param cal The <code>Calendar</code> to use for calculating timezones. + * + * @return The value of the column as a <code>java.sql.Time</code>. + * + * @exception SQLException If an error occurs. + */ +public abstract java.sql.Time +getTime(String name, Calendar cal) throws SQLException; + +/*************************************************************************/ + +/** + * This method returns the specified column value as a + * <code>java.sql.Timestamp</code>. The specified <code>Calendar</code> is used + * to generate a value for the timestamp if the database does not support + * timezones. + * + * @param name The name of the column value to return. + * @param cal The <code>Calendar</code> to use for calculating timezones. + * + * @return The value of the column as a <code>java.sql.Timestamp</code>. + * + * @exception SQLException If an error occurs. + */ +public abstract java.sql.Timestamp +getTimestamp(String name, Calendar cal) throws SQLException; + } // interface ResultSet diff --git a/libjava/java/sql/ResultSetMetaData.java b/libjava/java/sql/ResultSetMetaData.java index ca6a69b..edb89da 100644 --- a/libjava/java/sql/ResultSetMetaData.java +++ b/libjava/java/sql/ResultSetMetaData.java @@ -1,5 +1,5 @@ /* ResultSetMetaData.java -- Returns information about the ResultSet - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 2000 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -358,5 +358,21 @@ isWritable(int index) throws SQLException; public abstract boolean isDefinitelyWritable(int index) throws SQLException; +/*************************************************************************/ + +/** + * This method returns the name of the Java class which will be used to + * create objects representing the data in this column. + * + * @param index The index of the column to check. + * + * @return The name of the Java class that will be used for values in + * this column. + * + * @exception SQLException If an error occurs. + */ +public abstract String +getColumnClassName(int index) throws SQLException; + } // interface ResultSetMetaData diff --git a/libjava/java/sql/SQLData.java b/libjava/java/sql/SQLData.java new file mode 100644 index 0000000..8340069 --- /dev/null +++ b/libjava/java/sql/SQLData.java @@ -0,0 +1,74 @@ +/* SQLData.java -- Custom mapping for a user defined datatype + Copyright (C) 1999, 2000 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ + + +package java.sql; + +/** + * This interface is used for mapping SQL data to user defined datatypes. + * + * @author Aaron M. Renn (arenn@urbanophile.com) + */ +public interface SQLData +{ + +/** + * This method returns the user defined datatype name for this object. + * + * @return The user defined data type name for this object. + * + * @exception SQLException If an error occurs. + */ +public abstract String +getSQLTypeName() throws SQLException; + +/*************************************************************************/ + +/** + * This method populates the data in the object from the specified stream. + * + * @param stream The stream to read the data from. + * @param name The data type name of the data on the stream. + * + * @exception SQLException If an error occurs. + */ +public abstract void +readSQL(SQLInput stream, String name) throws SQLException; + +/*************************************************************************/ + +/** + * This method writes the data in this object to the specified stream. + * + * @param stream The stream to write the data to. + * + * @exception SQLException If an error occurs. + */ +public abstract void +writeSQL(SQLOutput stream) throws SQLException; + +} // interface SQLData + diff --git a/libjava/java/sql/SQLException.java b/libjava/java/sql/SQLException.java index 650d3c6..a65d947 100644 --- a/libjava/java/sql/SQLException.java +++ b/libjava/java/sql/SQLException.java @@ -32,7 +32,7 @@ package java.sql; * * @author Aaron M. Renn (arenn@urbanophile.com) */ -public class SQLException extends Exception implements java.io.Serializable +public class SQLException extends Exception { /*************************************************************************/ @@ -59,6 +59,15 @@ private String SQLState; */ private int vendorCode; +/*************************************************************************/ + +/** + * Static Variables + */ + +/** + * This is the serialization UID for this class + */ private static final long serialVersionUID = 2135244094396331484L; /*************************************************************************/ diff --git a/libjava/java/sql/SQLInput.java b/libjava/java/sql/SQLInput.java new file mode 100644 index 0000000..2f9fd07 --- /dev/null +++ b/libjava/java/sql/SQLInput.java @@ -0,0 +1,332 @@ +/* SQLInput.java -- Read SQL values from a stream + Copyright (C) 1999, 2000 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ + + +package java.sql; + +import java.io.InputStream; +import java.io.Reader; +import java.math.BigDecimal; + +/** + * This interface provides methods for reading values from a stream + * that is connected to a SQL structured or distinct type. It is used + * for custom mapping of user defined data types. + * + * @author Aaron M. Renn (arenn@urbanophile.com) + */ +public interface SQLInput +{ + +/*************************************************************************/ + +/** + * This method reads the next item from the stream a Java + * <code>String</code>. + * + * @return The value read from the stream as a <code>String</code>. + * + * @exception SQLException If an error occurs. + */ +public abstract String +readString() throws SQLException; + +/*************************************************************************/ + +/** + * This method reads the next item from the stream a Java + * <code>boolean</code>. + * + * @return The value read from the stream as a <code>boolean</code>. + * + * @exception SQLException If an error occurs. + */ +public abstract boolean +readBoolean() throws SQLException; + +/*************************************************************************/ + +/** + * This method reads the next item from the stream a Java + * <code>byte</code>. + * + * @return The value read from the stream as a <code>byte</code>. + * + * @exception SQLException If an error occurs. + */ +public abstract byte +readByte() throws SQLException; + +/*************************************************************************/ + +/** + * This method reads the next item from the stream a Java + * <code>short</code>. + * + * @return The value read from the stream as a <code>short</code>. + * + * @exception SQLException If an error occurs. + */ +public abstract short +readShort() throws SQLException; + +/*************************************************************************/ + +/** + * This method reads the next item from the stream a Java + * <code>int</code>. + * + * @return The value read from the stream as an <code>int</code>. + * + * @exception SQLException If an error occurs. + */ +public abstract int +readInt() throws SQLException; + +/*************************************************************************/ + +/** + * This method reads the next item from the stream a Java + * <code>long</code>. + * + * @return The value read from the stream as a <code>long</code>. + * + * @exception SQLException If an error occurs. + */ +public abstract long +readLong() throws SQLException; + +/*************************************************************************/ + +/** + * This method reads the next item from the stream a Java + * <code>float</code>. + * + * @return The value read from the stream as a <code>float</code>. + * + * @exception SQLException If an error occurs. + */ +public abstract float +readFloat() throws SQLException; + +/*************************************************************************/ + +/** + * This method reads the next item from the stream a Java + * <code>double</code>. + * + * @return The value read from the stream as a <code>double</code>. + * + * @exception SQLException If an error occurs. + */ +public abstract double +readDouble() throws SQLException; + +/*************************************************************************/ + +/** + * This method reads the next item from the stream a Java + * <code>BigDecimal</code>. + * + * @return The value read from the stream as a <code>BigDecimal</code>. + * + * @exception SQLException If an error occurs. + */ +public abstract BigDecimal +readBigDecimal() throws SQLException; + +/*************************************************************************/ + +/** + * This method reads the next item from the stream a Java + * byte array + * + * @return The value read from the stream as a byte array. + * + * @exception SQLException If an error occurs. + */ +public abstract byte[] +readBytes() throws SQLException; + +/*************************************************************************/ + +/** + * This method reads the next item from the stream a Java + * <code>java.sql.Date</code>. + * + * @return The value read from the stream as a <code>java.sql.Date</code>. + * + * @exception SQLException If an error occurs. + */ +public abstract java.sql.Date +readDate() throws SQLException; + +/*************************************************************************/ + +/** + * This method reads the next item from the stream a Java + * <code>java.sql.Time</code>. + * + * @return The value read from the stream as a <code>java.sql.Time</code>. + * + * @exception SQLException If an error occurs. + */ +public abstract java.sql.Time +readTime() throws SQLException; + +/*************************************************************************/ + +/** + * This method reads the next item from the stream a Java + * <code>java.sql.Timestamp</code>. + * + * @return The value read from the stream as a <code>java.sql.Timestamp</code>. + * + * @exception SQLException If an error occurs. + */ +public abstract java.sql.Timestamp +readTimestamp() throws SQLException; + +/*************************************************************************/ + +/** + * This method reads the next item from the stream a ASCII text + * <code>InputStream</code>. + * + * @return The value read from the stream as an <code>InputStream</code>. + * + * @exception SQLException If an error occurs. + */ +public abstract InputStream +readAsciiStream() throws SQLException; + +/*************************************************************************/ + +/** + * This method reads the next item from the stream a binary + * <code>InputStream</code>. + * + * @return The value read from the stream as an <code>InputStream</code>. + * + * @exception SQLException If an error occurs. + */ +public abstract InputStream +readBinaryStream() throws SQLException; + +/*************************************************************************/ + +/** + * This method reads the next item from the stream a character + * <code>Reader</code>. + * + * @return The value read from the stream as a <code>Reader</code>. + * + * @exception SQLException If an error occurs. + */ +public abstract Reader +readCharacterStream() throws SQLException; + +/*************************************************************************/ + +/** + * This method reads the next item from the stream a Java + * <code>Object</code>. + * + * @return The value read from the stream as an <code>Object</code>. + * + * @exception SQLException If an error occurs. + */ +public abstract Object +readObject() throws SQLException; + +/*************************************************************************/ + +/** + * This method reads the next item from the stream a Java SQL + * <code>Ref</code>. + * + * @return The value read from the stream as an <code>Ref</code>. + * + * @exception SQLException If an error occurs. + */ +public abstract Ref +readRef() throws SQLException; + +/*************************************************************************/ + +/** + * This method reads the next item from the stream a Java SQL + * <code>Blob</code>. + * + * @return The value read from the stream as a <code>Blob</code>. + * + * @exception SQLException If an error occurs. + */ +public abstract Blob +readBlob() throws SQLException; + +/*************************************************************************/ + +/** + * This method reads the next item from the stream a Java SQL + * <code>Clob</code>. + * + * @return The value read from the stream as a <code>Clob</code>. + * + * @exception SQLException If an error occurs. + */ +public abstract Clob +readClob() throws SQLException; + +/*************************************************************************/ + +/** + * This method reads the next item from the stream a Java SQL + * <code>Array</code>. + * + * @return The value read from the stream as an <code>Array</code>. + * + * @exception SQLException If an error occurs. + */ +public abstract Array +readArray() throws SQLException; + +/*************************************************************************/ + +/** + * This method tests whether or not the last value read was a SQL + * NULL value. + * + * @return <code>true</code> if the last value read was a NULL, + * <code>false</code> otherwise. + * + * @exception SQLException If an error occurs. + */ +public abstract boolean +wasNull() throws SQLException; + +} // interface SQLInput + diff --git a/libjava/java/sql/SQLOutput.java b/libjava/java/sql/SQLOutput.java new file mode 100644 index 0000000..c73e194 --- /dev/null +++ b/libjava/java/sql/SQLOutput.java @@ -0,0 +1,331 @@ +/* SQLOutput.java -- Write SQL values to a stream + Copyright (C) 1999, 2000 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ + + +package java.sql; + +import java.io.InputStream; +import java.io.Reader; +import java.math.BigDecimal; + +/** + * This interface provides methods for writing Java types to a SQL stream. + * It is used for implemented custom type mappings for user defined data + * types. + * + * @author Aaron M. Renn (arenn@urbanophile.com) + */ +public interface SQLOutput +{ + +/*************************************************************************/ + +/** + * This method writes the specified Java <code>String</code> + * to the SQL stream. + * + * @param value The value to write to the stream. + * + * @exception SQLException If an error occurs. + */ +public abstract void +writeString(String value) throws SQLException; + +/*************************************************************************/ + +/** + * This method writes the specified Java <code>boolean</code> + * to the SQL stream. + * + * @param value The value to write to the stream. + * + * @exception SQLException If an error occurs. + */ +public abstract void +writeBoolean(boolean value) throws SQLException; + +/*************************************************************************/ + +/** + * This method writes the specified Java <code>byte</code> + * to the SQL stream. + * + * @param value The value to write to the stream. + * + * @exception SQLException If an error occurs. + */ +public abstract void +writeByte(byte value) throws SQLException; + +/*************************************************************************/ + +/** + * This method writes the specified Java <code>short</code> + * to the SQL stream. + * + * @param value The value to write to the stream. + * + * @exception SQLException If an error occurs. + */ +public abstract void +writeShort(short value) throws SQLException; + +/*************************************************************************/ + +/** + * This method writes the specified Java <code>int</code> + * to the SQL stream. + * + * @param value The value to write to the stream. + * + * @exception SQLException If an error occurs. + */ +public abstract void +writeInt(int value) throws SQLException; + +/*************************************************************************/ + +/** + * This method writes the specified Java <code>long</code> + * to the SQL stream. + * + * @param value The value to write to the stream. + * + * @exception SQLException If an error occurs. + */ +public abstract void +writeLong(long value) throws SQLException; + +/*************************************************************************/ + +/** + * This method writes the specified Java <code>float</code> + * to the SQL stream. + * + * @param value The value to write to the stream. + * + * @exception SQLException If an error occurs. + */ +public abstract void +writeFloat(float value) throws SQLException; + +/*************************************************************************/ + +/** + * This method writes the specified Java <code>double</code> + * to the SQL stream. + * + * @param value The value to write to the stream. + * + * @exception SQLException If an error occurs. + */ +public abstract void +writeDouble(double value) throws SQLException; + +/*************************************************************************/ + +/** + * This method writes the specified Java <code>BigDecimal</code> + * to the SQL stream. + * + * @param value The value to write to the stream. + * + * @exception SQLException If an error occurs. + */ +public abstract void +writeBigDecimal(BigDecimal value) throws SQLException; + +/*************************************************************************/ + +/** + * This method writes the specified Java <code>byte</code> array + * to the SQL stream. + * + * @param value The value to write to the stream. + * + * @exception SQLException If an error occurs. + */ +public abstract void +writeBytes(byte[] value) throws SQLException; + +/*************************************************************************/ + +/** + * This method writes the specified Java <code>java.sql.Date</code> + * to the SQL stream. + * + * @param value The value to write to the stream. + * + * @exception SQLException If an error occurs. + */ +public abstract void +writeDate(java.sql.Date value) throws SQLException; + +/*************************************************************************/ + +/** + * This method writes the specified Java <code>java.sql.Time</code> + * to the SQL stream. + * + * @param value The value to write to the stream. + * + * @exception SQLException If an error occurs. + */ +public abstract void +writeTime(java.sql.Time value) throws SQLException; + +/*************************************************************************/ + +/** + * This method writes the specified Java <code>java.sql.Timestamp</code> + * to the SQL stream. + * + * @param value The value to write to the stream. + * + * @exception SQLException If an error occurs. + */ +public abstract void +writeTimestamp(java.sql.Timestamp value) throws SQLException; + +/*************************************************************************/ + +/** + * This method writes the specified Java character stream + * to the SQL stream. + * + * @param value The value to write to the stream. + * + * @exception SQLException If an error occurs. + */ +public abstract void +writeCharacterStream(Reader value) throws SQLException; + +/*************************************************************************/ + +/** + * This method writes the specified uninterpreted binary byte stream + * to the SQL stream. + * + * @param value The value to write to the stream. + * + * @exception SQLException If an error occurs. + */ +public abstract void +writeBinaryStream(InputStream value) throws SQLException; + +/*************************************************************************/ + +/** + * This method writes the specified ASCII text stream + * to the SQL stream. + * + * @param value The value to write to the stream. + * + * @exception SQLException If an error occurs. + */ +public abstract void +writeAsciiStream(InputStream value) throws SQLException; + +/*************************************************************************/ + +/** + * This method writes the specified Java <code>SQLData</code> object + * to the SQL stream. + * + * @param value The value to write to the stream. + * + * @exception SQLException If an error occurs. + */ +public abstract void +writeObject(SQLData value) throws SQLException; + +/*************************************************************************/ + +/** + * This method writes the specified Java SQL <code>Ref</code> object + * to the SQL stream. + * + * @param value The value to write to the stream. + * + * @exception SQLException If an error occurs. + */ +public abstract void +writeRef(Ref value) throws SQLException; + +/*************************************************************************/ + +/** + * This method writes the specified Java SQL <code>Blob</code> object + * to the SQL stream. + * + * @param value The value to write to the stream. + * + * @exception SQLException If an error occurs. + */ +public abstract void +writeBlob(Blob value) throws SQLException; + +/*************************************************************************/ + +/** + * This method writes the specified Java SQL <code>Clob</code> object + * to the SQL stream. + * + * @param value The value to write to the stream. + * + * @exception SQLException If an error occurs. + */ +public abstract void +writeClob(Clob value) throws SQLException; + +/*************************************************************************/ + +/** + * This method writes the specified Java SQL <code>Struct</code> object + * to the SQL stream. + * + * @param value The value to write to the stream. + * + * @exception SQLException If an error occurs. + */ +public abstract void +writeStruct(Struct value) throws SQLException; + +/*************************************************************************/ + +/** + * This method writes the specified Java SQL <code>Array</code> object + * to the SQL stream. + * + * @param value The value to write to the stream. + * + * @exception SQLException If an error occurs. + */ +public abstract void +writeArray(Array value) throws SQLException; + +} // interface SQLOutput + diff --git a/libjava/java/sql/SQLWarning.java b/libjava/java/sql/SQLWarning.java index 0318262..4f9c736 100644 --- a/libjava/java/sql/SQLWarning.java +++ b/libjava/java/sql/SQLWarning.java @@ -32,11 +32,22 @@ package java.sql; * * @author Aaron M. Renn (arenn@urbanophile.com) */ -public class SQLWarning extends SQLException implements java.io.Serializable +public class SQLWarning extends SQLException { /*************************************************************************/ +/** + * Static Variables + */ + +/** + * This is the serialization UID for this class + */ +private static final long serialVersionUID = 3917336774604784856L; + +/*************************************************************************/ + /* * Constructors */ @@ -132,7 +143,5 @@ setNextWarning(SQLWarning e) super.setNextException(e); } -private static final long serialVersionUID = 3917336774604784856L; - } // class SQLWarning diff --git a/libjava/java/sql/Statement.java b/libjava/java/sql/Statement.java index 1ceeb0f..30eeeeb 100644 --- a/libjava/java/sql/Statement.java +++ b/libjava/java/sql/Statement.java @@ -1,5 +1,5 @@ /* Statement.java -- Interface for executing SQL statements. - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 2000 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -273,5 +273,141 @@ getUpdateCount() throws SQLException; public abstract boolean getMoreResults() throws SQLException; +/*************************************************************************/ + +/** + * This method returns the current direction that the driver thinks the + * result set will be accessed int. + * + * @return The direction the result set will be accessed in (????) + * + * @exception SQLException If an error occurs. + */ +public abstract int +getFetchDirection() throws SQLException; + +/*************************************************************************/ + +/** + * This method informs the driver which direction the result set will + * be accessed in. + * + * @param direction The direction the result set will be accessed in (?????) + * + * @exception SQLException If an error occurs. + */ +public abstract void +setFetchDirection(int direction) throws SQLException; + +/*************************************************************************/ + +/** + * This method returns the number of rows the driver believes should be + * fetched from the database at a time. + * + * @return The number of rows that will be fetched from the database at a time. + * + * @exception SQLException If an error occurs. + */ +public abstract int +getFetchSize() throws SQLException; + +/*************************************************************************/ + +/** + * This method informs the driver how many rows it should fetch from the + * database at a time. + * + * @param numrows The number of rows the driver should fetch at a time + * to populate the result set. + * + * @exception SQLException If an error occurs. + */ +public abstract void +setFetchSize(int numrows) throws SQLException; + +/*************************************************************************/ + +/** + * This method returns the concurrency type of the result set for this + * statement. This will be one of the concurrency types defined in + * <code>ResultSet</code>. + * + * @return The concurrency type of the result set for this statement. + * + * @exception SQLException If an error occurs. + * + * @see ResultSet + */ +public abstract int +getResultSetConcurrency() throws SQLException; + +/*************************************************************************/ + +/** + * This method returns the result set type for this statement. This will + * be one of the result set types defined in <code>ResultSet</code>. + * + * @return The result set type for this statement. + * + * @exception SQLException If an error occurs. + * + * @see ResultSet + */ +public abstract int +getResultSetType() throws SQLException; + +/*************************************************************************/ + +/** + * This method adds a SQL statement to a SQL batch. A driver is not + * required to implement this method. + * + * @param sql The sql statement to add to the batch. + * + * @exception SQLException If an error occurs. + */ +public abstract void +addBatch(String sql) throws SQLException; + +/*************************************************************************/ + +/** + * This method clears out any SQL statements that have been populated in + * the current batch. A driver is not required to implement this method. + * + * @exception SQLException If an error occurs. + */ +public abstract void +clearBatch() throws SQLException; + +/*************************************************************************/ + +/** + * This method executes the SQL batch and returns an array of update + * counts - one for each SQL statement in the batch - ordered in the same + * order the statements were added to the batch. A driver is not required + * to implement this method. + * + * @return An array of update counts for this batch. + * + * @exception SQLException If an error occurs. + */ +public abstract int[] +executeBatch() throws SQLException; + +/*************************************************************************/ + +/** + * This method returns the <code>Connection</code> instance that was + * used to create this object. + * + * @return The connection used to create this object. + * + * @exception SQLException If an error occurs. + */ +public abstract Connection +getConnection() throws SQLException; + } // interface Statement diff --git a/libjava/java/sql/Struct.java b/libjava/java/sql/Struct.java new file mode 100644 index 0000000..779b5bc --- /dev/null +++ b/libjava/java/sql/Struct.java @@ -0,0 +1,80 @@ +/* Struct.java -- Mapping for a SQL structured type. + Copyright (C) 1999, 2000 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ + + +package java.sql; + +import java.util.Map; + +/** + * This interface implements the standard type mapping for a SQL + * structured type. + * + * @author Aaron M. Renn (arenn@urbanophile.com) + */ +public interface Struct +{ + +/** + * This method returns the name of the SQL structured type for this + * object. + * + * @return The SQL structured type name. + * + * @exception SQLException If an error occurs. + */ +public abstract String +getSQLTypeName() throws SQLException; + +/*************************************************************************/ + +/** + * This method returns the attributes of this SQL structured type. + * + * @return The attributes of this structure type. + * + * @exception SQLException If an error occurs. + */ +public abstract Object[] +getAttributes() throws SQLException; + +/*************************************************************************/ + +/** + * This method returns the attributes of this SQL structured type. + * The specified map of type mappings overrides the default mappings. + * + * @param map The map of SQL type mappings. + * + * @return The attributes of this structure type. + * + * @exception SQLException If a error occurs. + */ +public abstract Object[] +getAttributes(Map map) throws SQLException; + +} // interface Struct + diff --git a/libjava/java/sql/Types.java b/libjava/java/sql/Types.java index 3cbbba92..5e734d0 100644 --- a/libjava/java/sql/Types.java +++ b/libjava/java/sql/Types.java @@ -59,6 +59,13 @@ public static final int VARBINARY = -3; public static final int LONGVARBINARY = -4; public static final int NULL = 0; public static final int OTHER = 1111; +public static final int JAVA_OBJECT = 2000; +public static final int DISTINCT = 2001; +public static final int STRUCT = 2002; +public static final int ARRAY = 2003; +public static final int BLOB = 2004; +public static final int CLOB = 2005; +public static final int REF = 2006; } // class Types |