diff options
Diffstat (limited to 'libjava/classpath/java/sql')
30 files changed, 9928 insertions, 0 deletions
diff --git a/libjava/classpath/java/sql/Array.java b/libjava/classpath/java/sql/Array.java new file mode 100644 index 000000000..5cea23e8a --- /dev/null +++ b/libjava/classpath/java/sql/Array.java @@ -0,0 +1,186 @@ +/* Array.java -- Interface for accessing SQL array object + Copyright (C) 1999, 2000, 2002, 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +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 +{ + /** + * Returns the name of the SQL type of the elements in this + * array. This name is database specific. + * + * @return The name of the SQL type of the elements in this array. + * @exception SQLException If an error occurs. + */ + String getBaseTypeName() throws SQLException; + + /** + * 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 + */ + int getBaseType() throws SQLException; + + /** + * 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. + */ + Object getArray() throws SQLException; + + /** + * 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. + */ + Object getArray(Map<String, Class<?>> map) throws SQLException; + + /** + * Returns a portion of this array starting at <code>start</code> + * into the array and continuing for <code>count</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 start 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. + */ + Object getArray(long start, int count) throws SQLException; + + /** + * This method returns a portion of this array starting at <code>start</code> + * into the array and continuing for <code>count</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 start 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. + */ + Object getArray(long start, int count, Map<String, Class<?>> map) + throws SQLException; + + /** + * 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 + */ + 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 + */ + ResultSet getResultSet(Map<String, Class<?>> map) throws SQLException; + + /** + * This method returns a portion of the array as a <code>ResultSet</code>. + * The returned portion will start at <code>start</code> into the + * array and up to <code>count</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 start The index into the array to start returning elements from. + * @param count 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 + */ + ResultSet getResultSet(long start, int count) throws SQLException; + + /** + * This method returns a portion of the array as a <code>ResultSet</code>. + * The returned portion will start at <code>start</code> into the + * array and up to <code>count</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.</p> + * + * @param start The index into the 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 elements of this array as a <code>ResultSet</code>. + * @exception SQLException If an error occurs. + * @see ResultSet + */ + ResultSet getResultSet(long start, int count, Map<String, Class<?>> map) + throws SQLException; +} diff --git a/libjava/classpath/java/sql/BatchUpdateException.java b/libjava/classpath/java/sql/BatchUpdateException.java new file mode 100644 index 000000000..6b88bbad7 --- /dev/null +++ b/libjava/classpath/java/sql/BatchUpdateException.java @@ -0,0 +1,141 @@ +/* BatchUpdateException.java -- Exception for batch oriented SQL errors + Copyright (C) 1999, 2000, 2002 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., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +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 +{ + static final long serialVersionUID = 5977529877145521757L; + + /** + * This is the array of update counts for the commands which completed + * successfully prior to the error. + */ + private int[] 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 vendorCode + * @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; + } + + /** + * 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 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; + } + + /** + * 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) + { + this.updateCounts = updateCounts; + } + + /** + * 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 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; + } +} diff --git a/libjava/classpath/java/sql/Blob.java b/libjava/classpath/java/sql/Blob.java new file mode 100644 index 000000000..00fe49f70 --- /dev/null +++ b/libjava/classpath/java/sql/Blob.java @@ -0,0 +1,157 @@ +/* Blob.java -- Access a SQL Binary Large OBject. + Copyright (C) 1999, 2000, 2002, 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package java.sql; + +import java.io.InputStream; +import java.io.OutputStream; + +/** + * This interface specified methods for accessing a SQL BLOB (Binary Large + * OBject) type. + * + * @author Aaron M. Renn (arenn@urbanophile.com) + * @since 1.2 + */ +public interface Blob +{ + /** + * This method returns the number of bytes in this <code>Blob</code>. + * + * @return The number of bytes in this <code>Blob</code>. + * @exception SQLException If an error occurs. + */ + long length() throws SQLException; + + /** + * This method returns up to the requested bytes of this <code>Blob</code> + * as a <code>byte</code> array. + * + * @param start The index into this <code>Blob</code> to start returning + * bytes from. + * @param count The requested number of bytes to return. + * @return The requested bytes from this <code>Blob</code>. + * @exception SQLException If an error occurs. + */ + byte[] getBytes(long start, int count) throws SQLException; + + /** + * This method returns a stream that will read the bytes of this + * <code>Blob</code>. + * + * @return A stream that will read the bytes of this <code>Blob</code>. + * @exception SQLException If an error occurs. + */ + InputStream getBinaryStream() throws SQLException; + + /** + * This method returns the index into this <code>Blob</code> at which the + * first instance of the specified bytes occur. The searching starts at the + * specified index into this <code>Blob</code>. + * + * @param pattern The byte pattern to search for. + * @param start The index into this <code>Blob</code> to start 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. + */ + long position(byte[] pattern, long start) throws SQLException; + + /** + * This method returns the index into this <code>Blob</code> at which the + * first instance of the specified pattern occurs. The searching starts at the + * specified index into this <code>Blob</code>. 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 start The index into this <code>Blob</code> to start 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. + */ + long position(Blob pattern, long start) throws SQLException; + + /** + * Writes the specified data into this <code>Blob</code>, starting at the + * specified index. + * + * @param start The index at which the writing starts. + * @param bytes The data to write. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + int setBytes(long start, byte[] bytes) throws SQLException; + + /** + * Writes a portion of the specified data into this <code>Blob</code>, + * starting at the specified index. + * + * @param startWrite The index into this <code>Blob</code> at which writing + * starts. + * @param bytes The data to write a portion of. + * @param startRead The offset into the data where the portion to copy starts. + * @param count The number of bytes to write. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + int setBytes(long startWrite, byte[] bytes, int startRead, int count) + throws SQLException; + + /** + * Returns a binary stream that writes into this <code>Blob</code>, + * starting at the specified index. + * + * @param start The index at which the writing starts. + * @return A binary stream to write into this <code>Blob</code>. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + OutputStream setBinaryStream(long start) throws SQLException; + + /** + * Truncates this <code>Blob</code> to be at most the specified number of + * bytes long. + * + * @param count The length this <code>Blob</code> is truncated to. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + void truncate(long count) throws SQLException; +} diff --git a/libjava/classpath/java/sql/CallableStatement.java b/libjava/classpath/java/sql/CallableStatement.java new file mode 100644 index 000000000..09d58704e --- /dev/null +++ b/libjava/classpath/java/sql/CallableStatement.java @@ -0,0 +1,961 @@ +/* CallableStatement.java -- A statement for calling stored procedures. + Copyright (C) 1999, 2000, 2002, 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package java.sql; + +import java.io.InputStream; +import java.io.Reader; +import java.math.BigDecimal; +import java.net.URL; +import java.util.Calendar; +import java.util.Map; + +/** + * This interface provides a mechanism for calling stored procedures. + * + * @author Aaron M. Renn (arenn@urbanophile.com) + */ +public interface CallableStatement extends PreparedStatement +{ + /** + * 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 sqlType The SQL type value from <code>Types</code>. + * @exception SQLException If an error occurs. + */ + void registerOutParameter(int index, int sqlType) + 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. + * @param sqlType The SQL type value from <code>Types</code>. + * @param scale The scale of the value that will be returned. + * @exception SQLException If an error occurs. + */ + void registerOutParameter(int index, int sqlType, int scale) + throws SQLException; + + /** + * This method tests whether the value of the last parameter that was fetched + * was actually a SQL NULL value. + * + * @return <code>true</code> if the last parameter fetched was a NULL, + * <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean wasNull() throws SQLException; + + /** + * This method returns the value of the specified parameter as a Java + * <code>String</code>. + * + * @param index The index of the parameter to return. + * @return The parameter value as a <code>String</code>. + * @exception SQLException If an error occurs. + */ + String getString(int index) 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. + * @return The parameter value as a <code>boolean</code>. + * @exception SQLException If an error occurs. + */ + boolean getBoolean(int index) throws SQLException; + + /** + * This method returns the value of the specified parameter as a Java + * <code>byte</code>. + * + * @param index The index of the parameter to return. + * @return The parameter value as a <code>byte</code>. + * @exception SQLException If an error occurs. + */ + byte getByte(int index) throws SQLException; + + /** + * This method returns the value of the specified parameter as a Java + * <code>short</code>. + * + * @param index The index of the parameter to return. + * @return The parameter value as a <code>short</code>. + * @exception SQLException If an error occurs. + */ + short getShort(int index) throws SQLException; + + /** + * This method returns the value of the specified parameter as a Java + * <code>int</code>. + * + * @param index The index of the parameter to return. + * @return The parameter value as a <code>int</code>. + * @exception SQLException If an error occurs. + */ + int getInt(int index) throws SQLException; + + /** + * This method returns the value of the specified parameter as a Java + * <code>long</code>. + * + * @param index The index of the parameter to return. + * @return The parameter value as a <code>long</code>. + * @exception SQLException If an error occurs. + */ + long getLong(int index) throws SQLException; + + /** + * This method returns the value of the specified parameter as a Java + * <code>float</code>. + * + * @param index The index of the parameter to return. + * @return The parameter value as a <code>float</code>. + * @exception SQLException If an error occurs. + */ + float getFloat(int index) throws SQLException; + + /** + * This method returns the value of the specified parameter as a Java + * <code>double</code>. + * + * @param index The index of the parameter to return. + * @return The parameter value as a <code>double</code>. + * @exception SQLException If an error occurs. + */ + double getDouble(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>. + * @exception SQLException If an error occurs. + * @deprecated Use getBigDecimal(int index) + * or getBigDecimal(String name) instead. + */ + BigDecimal getBigDecimal(int index, int scale) + throws SQLException; + + /** + * This method returns the value of the specified parameter as a Java + * byte array. + * + * @param index The index of the parameter to return. + * @return The parameter value as a byte array + * @exception SQLException If an error occurs. + */ + byte[] getBytes(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. + * @return The parameter value as a <code>java.sql.Date</code>. + * @exception SQLException If an error occurs. + */ + Date getDate(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. + * @return The parameter value as a <code>java.sql.Time</code>. + * @exception SQLException If an error occurs. + */ + Time getTime(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. + * @return The parameter value as a <code>java.sql.Timestamp</code>. + * @exception SQLException If an error occurs. + */ + Timestamp getTimestamp(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. + * @return The parameter value as an <code>Object</code>. + * @exception SQLException If an error occurs. + * @since 1.2 + */ + Object getObject(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. + * @return The parameter value as a <code>BigDecimal</code>. + * @exception SQLException If an error occurs. + * @since 1.2 + */ + BigDecimal getBigDecimal(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. + * @since 1.2 + */ + Object getObject(int index, Map<String, Class<?>> map) 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. + * @since 1.2 + */ + 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. + * @since 1.2 + */ + 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. + * @since 1.2 + */ + 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. + * @since 1.2 + */ + Array getArray(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 cal 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. + * @since 1.2 + */ + Date getDate(int index, Calendar cal) 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 cal 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. + * @since 1.2 + */ + Time getTime(int index, Calendar cal) 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. + * @return The parameter value as a <code>java.sql.Timestamp</code>. + * @exception SQLException If an error occurs. + * @since 1.2 + */ + Timestamp getTimestamp(int index, Calendar cal) + 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 sqlType The SQL type value from <code>Types</code>. + * @param typeName The user defined data type name. + * @exception SQLException If an error occurs. + * @since 1.2 + */ + void registerOutParameter(int index, int sqlType, String typeName) + throws SQLException; + + /** + * This method registers the specified parameter as an output parameter + * of the specified SQL type. + * + * @param name The name of the parameter to register as output. + * @param sqlType The SQL type value from <code>Types</code>. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + void registerOutParameter(String name, int sqlType) + throws SQLException; + + /** + * This method registers the specified parameter as an output parameter + * of the specified SQL type. This version of registerOutParameter is used + * for NUMERIC or DECIMAL types. + * + * @param name The name of the parameter to register as output. + * @param sqlType The SQL type value from <code>Types</code>. + * @param scale Number of digits to the right of the decimal point. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + void registerOutParameter(String name, int sqlType, int scale) + throws SQLException; + + + /** + * This method registers the specified parameter as an output parameter + * of the specified SQL type. This version of registerOutParameter is used + * for user-named or REF types. If the type of the output parameter does + * not have such a type, the typeName argument is ignored. + * + * @param name The name of the parameter to register as output. + * @param sqlType The SQL type value from <code>Types</code>. + * @param typeName The SQL structured type name. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + void registerOutParameter(String name, int sqlType, String typeName) + throws SQLException; + + /** + * This method returns the value of the specified parameter as a Java + * <code>java.net.URL</code>. + * + * @param index The index of the parameter to return. + * @return The parameter value as a <code>URL</code>. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + URL getURL(int index) throws SQLException; + + /** + * This method sets the value of the specified parameter to the specified + * <code>java.net.URL</code> + * + * @param name The name of the parameter to set. + * @param value The value the parameter. + * @since 1.4 + */ + void setURL(String name, URL value) throws SQLException; + + /** + * This method populates the specified parameter with a SQL NULL value + * for the specified type. + * + * @param name The name of the parameter to set. + * @param sqlType The SQL type identifier of the parameter from + * <code>Types</code> + * @exception SQLException If an error occurs. + * @since 1.4 + */ + void setNull(String name, int sqlType) throws SQLException; + + /** + * This method sets the specified parameter from the given Java + * <code>boolean</code> value. + * + * @param name The name of the parameter value to set. + * @param value The value of the parameter. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + void setBoolean(String name, boolean value) throws SQLException; + + /** + * This method sets the specified parameter from the given Java + * <code>byte</code> value. + * + * @param name The name of the parameter value to set. + * @param value The value of the parameter. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + void setByte(String name, byte value) throws SQLException; + + /** + * This method sets the specified parameter from the given Java + * <code>short</code> value. + * + * @param name The name of the parameter value to set. + * @param value The value of the parameter. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + void setShort(String name, short value) throws SQLException; + + /** + * This method sets the specified parameter from the given Java + * <code>int</code> value. + * + * @param name The name of the parameter value to set. + * @param value The value of the parameter. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + void setInt(String name, int value) throws SQLException; + + /** + * This method sets the specified parameter from the given Java + * <code>long</code> value. + * + * @param name The name of the parameter value to set. + * @param value The value of the parameter. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + void setLong(String name, long value) throws SQLException; + + /** + * This method sets the specified parameter from the given Java + * <code>float</code> value. + * + * @param name The name of the parameter value to set. + * @param value The value of the parameter. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + void setFloat(String name, float value) throws SQLException; + + /** + * This method sets the specified parameter from the given Java + * <code>double</code> value. + * + * @param name The name of the parameter value to set. + * @param value The value of the parameter. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + void setDouble(String name, double value) throws SQLException; + + /** + * This method sets the specified parameter from the given Java + * <code>BigDecimal</code> value. + * + * @param name The name of the parameter value to set. + * @param value The value of the parameter. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + void setBigDecimal(String name, BigDecimal value) + throws SQLException; + + /** + * This method sets the specified parameter from the given Java + * <code>String</code> value. + * + * @param name The name of the parameter value to set. + * @param value The value of the parameter. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + void setString(String name, String value) throws SQLException; + + /** + * This method sets the specified parameter from the given Java + * <code>byte</code> array value. + * + * @param name The name of the parameter value to set. + * @param value The value of the parameter. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + void setBytes(String name, byte[] value) throws SQLException; + + /** + * This method sets the specified parameter from the given Java + * <code>java.sql.Date</code> value. + * + * @param name The name of the parameter value to set. + * @param value The value of the parameter. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + void setDate(String name, Date value) throws SQLException; + + /** + * This method sets the specified parameter from the given Java + * <code>java.sql.Time</code> value. + * + * @param name The name of the parameter value to set. + * @param value The value of the parameter. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + void setTime(String name, Time value) throws SQLException; + + /** + * This method sets the specified parameter from the given Java + * <code>java.sql.Timestamp</code> value. + * + * @param name The name of the parameter value to set. + * @param value The value of the parameter. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + void setTimestamp(String name, Timestamp value) + throws SQLException; + + /** + * This method sets the specified parameter from the given Java + * ASCII <code>InputStream</code> value. + * + * @param name The name of the parameter value to set. + * @param stream The stream from which the parameter value is read. + * @param count The number of bytes in the stream. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + void setAsciiStream(String name, InputStream stream, int count) + throws SQLException; + + /** + * This method sets the specified parameter from the given Java + * binary <code>InputStream</code> value. + * + * @param name The name of the parameter value to set. + * @param stream The stream from which the parameter value is read. + * @param count The number of bytes in the stream. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + void setBinaryStream(String name, InputStream stream, int count) + throws SQLException; + + /** + * This method sets the specified parameter from the given Java + * <code>Object</code> value. The specified SQL object type will be used. + * + * @param name The name of the parameter value to set. + * @param value The value of the parameter. + * @param sqlType The SQL type to use for the parameter, from + * <code>Types</code> + * @param scale The scale of the value, for numeric values only. + * @exception SQLException If an error occurs. + * @see Types + * @since 1.4 + */ + void setObject(String name, Object value, int sqlType, int scale) + throws SQLException; + + /** + * This method sets the specified parameter from the given Java + * <code>Object</code> value. The specified SQL object type will be used. + * + * @param name The name of the parameter value to set. + * @param value The value of the parameter. + * @param sqlType The SQL type to use for the parameter, from + * <code>Types</code> + * @exception SQLException If an error occurs. + * @see Types + * @since 1.4 + */ + void setObject(String name, Object value, int sqlType) + 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. + * + * @param name The name of the parameter value to set. + * @param value The value of the parameter. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + void setObject(String name, Object value) throws SQLException; + + /** + * This method sets the specified parameter from the given Java + * character <code>Reader</code> value. + * + * @param name The name of the parameter value to set. + * @param reader The reader from which the parameter value is read. + * @param count The number of characters in the stream. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + void setCharacterStream(String name, Reader reader, int count) + throws SQLException; + + /** + * This method sets the specified parameter from the given Java + * <code>java.sql.Date</code> value. + * + * @param name The name of the parameter value to set. + * @param value The value of the parameter. + * @param cal The <code>Calendar</code> to use for timezone and locale. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + void setDate(String name, Date value, Calendar cal) + throws SQLException; + + /** + * This method sets the specified parameter from the given Java + * <code>java.sql.Time</code> value. + * + * @param name The name of the parameter value to set. + * @param value The value of the parameter. + * @param cal The <code>Calendar</code> to use for timezone and locale. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + void setTime(String name, Time value, Calendar cal) + throws SQLException; + + /** + * This method sets the specified parameter from the given Java + * <code>java.sql.Timestamp</code> value. + * + * @param name The name of the parameter value to set. + * @param value The value of the parameter. + * @param cal The <code>Calendar</code> to use for timezone and locale. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + void setTimestamp(String name, Timestamp value, Calendar cal) + throws SQLException; + + /** + * This method populates the specified parameter with a SQL NULL value + * for the specified type. + * + * @param name The name of the parameter to set. + * @param sqlType The SQL type identifier of the parameter from + * <code>Types</code> + * @param typeName The name of the data type, for user defined types. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + void setNull(String name, int sqlType, String typeName) + throws SQLException; + + /** + * This method returns the value of the specified parameter as a Java + * <code>String</code>. + * + * @param name The name of the parameter to return. + * @return The parameter value as a <code>String</code>. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + String getString(String name) throws SQLException; + + /** + * This method returns the value of the specified parameter as a Java + * <code>boolean</code>. + * + * @param name The name of the parameter to return. + * @return The parameter value as a <code>boolean</code>. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + boolean getBoolean(String name) throws SQLException; + + /** + * This method returns the value of the specified parameter as a Java + * <code>byte</code>. + * + * @param name The name of the parameter to return. + * @return The parameter value as a <code>byte</code>. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + byte getByte(String name) throws SQLException; + + /** + * This method returns the value of the specified parameter as a Java + * <code>short</code>. + * + * @param name The name of the parameter to return. + * @return The parameter value as a <code>short</code>. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + short getShort(String name) throws SQLException; + + /** + * This method returns the value of the specified parameter as a Java + * <code>int</code>. + * + * @param name The name of the parameter to return. + * @return The parameter value as a <code>int</code>. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + int getInt(String name) throws SQLException; + + /** + * This method returns the value of the specified parameter as a Java + * <code>long</code>. + * + * @param name The name of the parameter to return. + * @return The parameter value as a <code>long</code>. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + long getLong(String name) throws SQLException; + + /** + * This method returns the value of the specified parameter as a Java + * <code>float</code>. + * + * @param name The name of the parameter to return. + * @return The parameter value as a <code>float</code>. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + float getFloat(String name) throws SQLException; + + /** + * This method returns the value of the specified parameter as a Java + * <code>double</code>. + * + * @param name The name of the parameter to return. + * @return The parameter value as a <code>double</code>. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + double getDouble(String name) throws SQLException; + + /** + * This method returns the value of the specified parameter as a Java + * <code>byte</code> array. + * + * @param name The name of the parameter to return. + * @return The parameter value as a <code>byte[]</code>. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + byte[] getBytes(String name) throws SQLException; + + /** + * This method returns the value of the specified parameter as a Java + * <code>java.sql.Date</code>. + * + * @param name The name of the parameter to return. + * @return The parameter value as a <code>java.sql.Date</code>. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + Date getDate(String name) throws SQLException; + + /** + * This method returns the value of the specified parameter as a Java + * <code>java.sql.Time</code>. + * + * @param name The name of the parameter to return. + * @return The parameter value as a <code>java.sql.Time</code>. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + Time getTime(String name) throws SQLException; + + /** + * This method returns the value of the specified parameter as a Java + * <code>java.sql.Timestamp</code>. + * + * @param name The name of the parameter to return. + * @return The parameter value as a <code>java.sql.Timestamp</code>. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + Timestamp getTimestamp(String name) throws SQLException; + + /** + * This method returns the value of the specified parameter as a Java + * <code>Object</code>. + * + * @param name The name of the parameter to return. + * @return The parameter value as a <code>Object</code>. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + Object getObject(String name) throws SQLException; + + /** + * This method returns the value of the specified parameter as a Java + * <code>BigDecimal</code>. + * + * @param name The name of the parameter to return. + * @return The parameter value as a <code>BigDecimal</code>. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + BigDecimal getBigDecimal(String name) throws SQLException; + + /** + * This method returns the value of the specified parameter as a Java + * <code>Object</code> using the specified mapping for conversion from + * SQL to Java types. + * + * @param name The name 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. + * @since 1.4 + */ + Object getObject(String name, Map<String, Class<?>> map) throws SQLException; + + /** + * This method returns the value of the specified parameter as a Java + * <code>Ref</code>. + * + * @param name The name of the parameter to return. + * @return The parameter value as a <code>Ref</code>. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + Ref getRef(String name) throws SQLException; + + /** + * This method returns the value of the specified parameter as a Java + * <code>Blob</code>. + * + * @param name The name of the parameter to return. + * @return The parameter value as a <code>Blob</code>. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + Blob getBlob(String name) throws SQLException; + + /** + * This method returns the value of the specified parameter as a Java + * <code>Clob</code>. + * + * @param name The name of the parameter to return. + * @return The parameter value as a <code>Clob</code>. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + Clob getClob(String name) throws SQLException; + + /** + * This method returns the value of the specified parameter as a Java + * <code>Array</code>. + * + * @param name The name of the parameter to return. + * @return The parameter value as a <code>Array</code>. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + Array getArray(String name) throws SQLException; + + /** + * This method returns the value of the specified parameter as a Java + * <code>java.sql.Date</code>. + * + * @param name The name of the parameter to return. + * @param cal 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. + * @since 1.4 + */ + Date getDate(String name, Calendar cal) throws SQLException; + + /** + * This method returns the value of the specified parameter as a Java + * <code>java.sql.Time</code>. + * + * @param name The name of the parameter to return. + * @param cal 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. + * @since 1.4 + */ + Time getTime(String name, Calendar cal) throws SQLException; + + /** + * This method returns the value of the specified parameter as a Java + * <code>java.sql.Timestamp</code>. + * + * @param name The name of the parameter to return. + * @param cal 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. + * @since 1.4 + */ + Timestamp getTimestamp(String name, Calendar cal) + throws SQLException; + + /** + * This method returns the value of the specified parameter as a Java + * <code>java.net.URL</code>. + * + * @param name The name of the parameter to return. + * @return The parameter value as a <code>java.net.URL</code>. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + URL getURL(String name) throws SQLException; +} diff --git a/libjava/classpath/java/sql/Clob.java b/libjava/classpath/java/sql/Clob.java new file mode 100644 index 000000000..483276e69 --- /dev/null +++ b/libjava/classpath/java/sql/Clob.java @@ -0,0 +1,187 @@ +/* Clob.java -- Access Character Large OBjects + Copyright (C) 1999, 2000, 2002, 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package java.sql; + +import java.io.InputStream; +import java.io.OutputStream; +import java.io.Reader; +import java.io.Writer; + +/** + * 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 this <code>Clob</code>. + * + * @return The number of characters in this <code>Clob</code>. + * @exception SQLException If an error occurs. + * @since 1.2 + */ + long length() throws SQLException; + + /** + * This method returns the specified portion of this <code>Clob</code> as a + * <code>String</code>. + * + * @param start The index into this <code>Clob</code> (index values + * start at 1) to start returning characters from. + * @param count The requested number of characters to return. + * @return The requested <code>Clob</code> section, as a <code>String</code>. + * @exception SQLException If an error occurs. + * @since 1.2 + */ + String getSubString(long start, int count) throws SQLException; + + /** + * This method returns a character stream that reads the contents of this + * <code>Clob</code>. + * + * @return A character stream to read this <code>Clob</code>'s contents. + * @exception SQLException If an error occurs. + * @since 1.2 + */ + Reader getCharacterStream() throws SQLException; + + /** + * This method returns a byte stream that reads the contents of this + * <code>Clob</code> as a series of ASCII bytes. + * + * @return A stream to read this <code>Clob</code>'s contents. + * @exception SQLException If an error occurs. + * @since 1.2 + */ + InputStream getAsciiStream() throws SQLException; + + /** + * This method returns the index into this <code>Clob</code> 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 start The index into this <code>Clob</code> to start searching + * (indices start at 1). + * @return The index at which the pattern was found (indices start at 1), or + * -1 if the pattern was not found. + * @exception SQLException If an error occurs. + * @since 1.2 + */ + long position(String pattern, long start) throws SQLException; + + /** + * This method returns the index into this <code>Clob</code> 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 start The index into this <code>Clob</code> to start searching + * (indices start at 1). + * @return The index at which the pattern was found (indices start at 1), or + * -1 if the pattern was not found. + * @exception SQLException If an error occurs. + * @since 1.2 + */ + long position(Clob pattern, long start) throws SQLException; + + /** + * Writes the specified string into this <code>Clob</code>, starting at the + * specified index. + * + * @param start The index at which the writing starts. + * @param value The string to write. + * @return The number of characters written. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + int setString(long start, String value) throws SQLException; + + /** + * Writes the specified portion of a string into this <code>Clob</code>, + * starting at the specified index. + * + * @param startWrite The index at which the writing starts. + * @param value The string to write a portion of. + * @param startRead The offset into the string where the portion to copy + * starts. + * @param count The number of characters to write. + * @return The number of characters written. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + int setString(long startWrite, String value, int startRead, int count) + throws SQLException; + + /** + * Returns an ASCII text stream that writes into this <code>Clob</code>, + * starting at the specified index. + * + * @param start The index at which the writing starts. + * @return An ASCII text stream to write into this <code>Clob</code>. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + OutputStream setAsciiStream(long start) throws SQLException; + + /** + * Returns a character stream that writes into this <code>Clob</code>, + * starting at the specified index. + * + * @param start The index at which the writing starts. + * @return A character stream to write into this <code>Clob</code>. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + Writer setCharacterStream(long start) throws SQLException; + + /** + * Truncates this <code>Clob</code> to be at most the specified number of + * characters long. + * + * @param count The length this <code>Clob</code> is truncated to. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + void truncate(long count) throws SQLException; +} diff --git a/libjava/classpath/java/sql/Connection.java b/libjava/classpath/java/sql/Connection.java new file mode 100644 index 000000000..f37527625 --- /dev/null +++ b/libjava/classpath/java/sql/Connection.java @@ -0,0 +1,500 @@ +/* Connection.java -- Manage a database connection. + Copyright (C) 1999, 2000, 2002, 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package java.sql; + +import java.util.Map; + +/** + * This interface provides methods for managing a connection to a database. + * + * @author Aaron M. Renn (arenn@urbanophile.com) + */ +public interface Connection +{ + /** + * This transaction isolation level indicates that transactions are not + * supported. + */ + int TRANSACTION_NONE = 0; + + /** + * This transaction isolation level indicates that one transaction can + * read modifications by other transactions before the other transactions + * have committed their changes. This could result in invalid reads. + */ + int TRANSACTION_READ_UNCOMMITTED = 1; + + /** + * This transaction isolation level indicates that only committed data from + * other transactions will be read. If a transaction reads a row, then + * another transaction commits a change to that row, the first transaction + * would retrieve the changed row on subsequent reads of the same row. + */ + int TRANSACTION_READ_COMMITTED = 2; + + /** + * This transaction isolation level indicates that only committed data from + * other transactions will be read. It also ensures that data read from + * a row will not be different on a subsequent read even if another + * transaction commits a change. + */ + int TRANSACTION_REPEATABLE_READ = 4; + + /** + * This transaction isolation level indicates that only committed data from + * other transactions will be read. It also ensures that data read from + * a row will not be different on a subsequent read even if another + * transaction commits a change. Additionally, rows modified by other + * transactions will not affect the result set returned during subsequent + * executions of the same WHERE clause in this transaction. + */ + int TRANSACTION_SERIALIZABLE = 8; + + /** + * This method creates a new SQL statement. The default result set type + * and concurrency will be used. + * + * @return A new <code>Statement</code> object. + * @exception SQLException If an error occurs. + * @see Statement + */ + Statement createStatement() 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. + * + * @param sql The SQL statement to use in creating this + * <code>PreparedStatement</code>. + * @return A new <code>PreparedStatement</code>. + * @exception SQLException If an error occurs. + * @see PreparedStatement + */ + PreparedStatement prepareStatement(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 default result set type and concurrency + * will be used. + * + * @param sql The SQL statement to use in creating this + * <code>CallableStatement</code>. + * @return A new <code>CallableStatement</code>. + * @exception SQLException If an error occurs. + * @see CallableStatement + */ + CallableStatement prepareCall(String sql) throws SQLException; + + /** + * This method converts the specified generic SQL statement into the + * native grammer of the database this object is connected to. + * + * @param sql The JDBC generic SQL statement. + * @return The native SQL statement. + * @exception SQLException If an error occurs. + */ + String nativeSQL(String sql) throws SQLException; + + /** + * This method turns auto commit mode on or off. In auto commit mode, + * every SQL statement is committed its own transaction. Otherwise a + * transaction must be explicitly committed or rolled back. + * + * @param autoCommit <code>true</code> to enable auto commit mode, + * <code>false</code> to disable it. + * @exception SQLException If an error occurs. + * @see #commit() + * @see #rollback() + */ + void setAutoCommit(boolean autoCommit) throws SQLException; + + /** + * This method tests whether or not auto commit mode is currently enabled. + * In auto commit mode, every SQL statement is committed its own transaction. + * Otherwise a transaction must be explicitly committed or rolled back. + * + * @return <code>true</code> if auto commit mode is enabled, + * <code>false</code> otherwise. + * @exception SQLException If an error occurs. + * @see #commit() + * @see #rollback() + */ + boolean getAutoCommit() throws SQLException; + + /** + * This method commits any SQL statements executed on this connection since + * the last commit or rollback. + * + * @exception SQLException If an error occurs. + */ + void commit() throws SQLException; + + /** + * This method rolls back any SQL statements executed on this connection + * since the last commit or rollback. + * + * @exception SQLException If an error occurs. + */ + void rollback() throws SQLException; + + /** + * This method immediately closes this database connection. + * + * @exception SQLException If an error occurs. + */ + void close() throws SQLException; + + /** + * This method tests whether or not this connection has been closed. + * + * @return <code>true</code> if the connection is closed, <code>false</code> + * otherwise. + * @exception SQLException If an error occurs. + */ + boolean isClosed() throws SQLException; + + /** + * This method returns the meta data for this database connection. + * + * @return The meta data for this database. + * @exception SQLException If an error occurs. + * @see DatabaseMetaData + */ + DatabaseMetaData getMetaData() throws SQLException; + + /** + * This method turns read only mode on or off. It may not be called while + * a transaction is in progress. + * + * @param readOnly <code>true</code> if this connection is read only, + * <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + void setReadOnly(boolean readOnly) throws SQLException; + + /** + * This method tests whether or not this connection is in read only mode. + * + * @return <code>true</code> if the connection is read only <code>false</code> + * otherwise. + * @exception SQLException If an error occurs. + */ + boolean isReadOnly() throws SQLException; + + /** + * This method sets the name of the catalog in use by this connection. + * Note that this method does nothing if catalogs are not supported by + * this database. + * + * @param catalog The name of the catalog to use for this connection. + * @exception SQLException If an error occurs. + */ + void setCatalog(String catalog) throws SQLException; + + /** + * This method returns the name of the catalog in use by this connection, + * if any. + * + * @return The name of the catalog, or <code>null</code> if none + * exists or catalogs are not supported by this database. + * @exception SQLException If an error occurs. + */ + String getCatalog() throws SQLException; + + /** + * 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. + * @exception SQLException If an error occurs. + */ + void setTransactionIsolation(int level) throws SQLException; + + /** + * This method returns the current transaction isolation mode. This will + * be one of the constants defined in this interface. + * + * @return The transaction isolation level. + * @exception SQLException If an error occurs. + */ + int getTransactionIsolation() throws SQLException; + + /** + * This method returns the first warning that occurred on this connection, + * if any. If there were any subsequence warnings, they will be chained + * to the first one. + * + * @return The first <code>SQLWarning</code> that occurred, or + * <code>null</code> if there have been no warnings. + * @exception SQLException If an error occurs. + */ + SQLWarning getWarnings() throws SQLException; + + /** + * This method clears all warnings that have occurred on this connection. + * + * @exception SQLException If an error occurs. + */ + void clearWarnings() 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 + */ + 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 specified result set type and concurrency will be used. + * Valid values for these parameters are specified in the + * <code>ResultSet</code> class. + * + * @param sql 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 + */ + 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 specified result set type and concurrency + * will be used. Valid values for these parameters are specified in the + * <code>ResultSet</code> class. + * + * @param sql 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 + */ + CallableStatement prepareCall(String sql, int resultSetType, int + resultSetConcurrency) 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. + */ + Map<String, Class<?>> 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. + */ + void setTypeMap(Map<String, Class<?>> map) throws SQLException; + + /** + * Sets the default holdability of <code>ResultSet</code>S that are created + * from <code>Statement</code>S using this <code>Connection</code>. + * + * @param holdability The default holdability value to set, this must be one + * of <code>ResultSet.HOLD_CURSORS_OVER_COMMIT</code> or + * <code>ResultSet.CLOSE_CURSORS_AT_COMMIT</code>. + * @exception SQLException If an error occurs. + * @see ResultSet + * @since 1.4 + */ + void setHoldability(int holdability) throws SQLException; + + /** + * Gets the default holdability of <code>ResultSet</code>S that are created + * from <code>Statement</code>S using this <code>Connection</code>. + * + * @return The current default holdability value, this must be one of + * <code>ResultSet.HOLD_CURSORS_OVER_COMMIT</code> or + * <code>ResultSet.CLOSE_CURSORS_AT_COMMIT</code>. + * @exception SQLException If an error occurs. + * @see ResultSet + * @since 1.4 + */ + int getHoldability() throws SQLException; + + /** + * Creates a new unnamed savepoint for this <code>Connection</code> + * + * @return The <code>Savepoint</code> object representing the savepoint. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + Savepoint setSavepoint() throws SQLException; + + /** + * Creates a new savepoint with the specifiend name for this + * <code>Connection</code>. + * + * @param name The name of the savepoint. + * @return The <code>Savepoint</code> object representing the savepoint. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + Savepoint setSavepoint(String name) throws SQLException; + + /** + * Undoes all changes made after the specified savepoint was set. + * + * @param savepoint The safepoint to roll back to. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + void rollback(Savepoint savepoint) throws SQLException; + + /** + * Removes the specified savepoint from this <code>Connection</code>. + * Refering to a savepoint after it was removed is an error and will throw an + * SQLException. + * + * @param savepoint The savepoint to release. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + void releaseSavepoint(Savepoint savepoint) throws SQLException; + + /** + * This method creates a new SQL statement with the specified type, + * concurrency and holdability, instead of using the defaults. 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. + * @param resultSetHoldability The type of holdability to be usd in the + * result set for this statement. + * @return A new <code>Statement</code> + * @exception SQLException If an error occurs. + * @see ResultSet + * @since 1.4 + */ + Statement createStatement(int resultSetType, int + resultSetConcurrency, int resultSetHoldability) 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, concurrency and holdability + * will be used. Valid values for these parameters are specified in the + * <code>ResultSet</code> class. + * + * @param sql 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. + * @param resultSetHoldability The type of holdability to be usd in the + * result set for this statement. + * @return A new <code>PreparedStatement</code>. + * @exception SQLException If an error occurs. + * @see PreparedStatement + * @see ResultSet + * @since 1.4 + */ + PreparedStatement prepareStatement(String sql, int resultSetType, int + resultSetConcurrency, int resultSetHoldability) 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, concurrency and + * holdability will be used. Valid values for these parameters are specified + * in the <code>ResultSet</code> class. + * + * @param sql 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. + * @param resultSetHoldability The type of holdability 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 + * @since 1.4 + */ + CallableStatement prepareCall(String sql, int resultSetType, int + resultSetConcurrency, int resultSetHoldability) throws SQLException; + + /** + * @since 1.4 + */ + PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) + throws SQLException; + + /** + * @since 1.4 + */ + PreparedStatement prepareStatement(String sql, int[] columnIndexes) + throws SQLException; + + /** + * @since 1.4 + */ + PreparedStatement prepareStatement(String sql, String[] columnNames) + throws SQLException; +} diff --git a/libjava/classpath/java/sql/DataTruncation.java b/libjava/classpath/java/sql/DataTruncation.java new file mode 100644 index 000000000..efa4487b3 --- /dev/null +++ b/libjava/classpath/java/sql/DataTruncation.java @@ -0,0 +1,157 @@ +/* DataTruncation.java -- Warning when data has been truncated. + Copyright (C) 1999, 2000, 2002 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., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package java.sql; + +/** + * This exception is thrown when a piece of data is unexpectedly + * truncated in JDBC. + * + * @author Aaron M. Renn (arenn@urbanophile.com) + */ +public class DataTruncation extends SQLWarning +{ + static final long serialVersionUID = 6464298989504059473L; + + /** + * The original size of the data. + */ + private int dataSize; + + /** + * The index of the parameter or column whose value was truncated. + */ + private int index; + + /** + * Indicates whether or not a parameter value was truncated. + */ + private boolean parameter; + + /** + * Indicates whether or not a data column value was truncated. + */ + private boolean read; + + /** + * This is the size of the data after truncation. + */ + private int transferSize; + + /** + * This method initializes a new instance of <code>DataTruncation</code> + * with the specified values. The descriptive error message for this + * exception will be "Data truncation", the SQL state will be "01004" + * and the vendor specific error code will be set to 0. + * + * @param index The index of the parameter or column that was truncated. + * @param parameter <code>true</code> if a parameter was truncated, + * <code>false</code> otherwise. + * @param read <code>true</code> if a data column was truncated, + * <code>false</code> otherwise. + * @param dataSize The original size of the data. + * @param transferSize The size of the data after truncation. + */ + public DataTruncation(int index, boolean parameter, boolean read, int + dataSize, int transferSize) + { + super("Data truncation", "01004"); + + this.index = index; + this.parameter = parameter; + this.read = read; + this.dataSize = dataSize; + this.transferSize = transferSize; + } + + /** + * This method returns the index of the column or parameter that was + * truncated. + * + * @return The index of the column or parameter that was truncated. + */ + public int getIndex() + { + return index; + } + + /** + * This method determines whether or not it was a parameter that was + * truncated. + * + * @return <code>true</code> if a parameter was truncated, <code>false</code> + * otherwise. + */ + public boolean getParameter() + { + return parameter; + } + + /** + * This method determines whether or not it was a column that was + * truncated. + * + * @return <code>true</code> if a column was truncated, <code>false</code> + * otherwise. + */ + public boolean getRead() + { + return read; + } + + /** + * This method returns the original size of the parameter or column that + * was truncated. + * + * @return The original size of the parameter or column that was truncated. + */ + public int getDataSize() + { + return dataSize; + } + + /** + * This method returns the size of the parameter or column after it was + * truncated. + * + * @return The size of the parameter or column after it was truncated. + */ + public int getTransferSize() + { + return transferSize; + } +} diff --git a/libjava/classpath/java/sql/DatabaseMetaData.java b/libjava/classpath/java/sql/DatabaseMetaData.java new file mode 100644 index 000000000..3ffd5b0df --- /dev/null +++ b/libjava/classpath/java/sql/DatabaseMetaData.java @@ -0,0 +1,2270 @@ +/* DatabaseMetaData.java -- Information about the database itself. + Copyright (C) 1999, 2000, 2001, 2002, 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package java.sql; + +public interface DatabaseMetaData +{ + /** + * It is unknown whether or not the procedure returns a result. + */ + int procedureResultUnknown = 0; + + /** + * The procedure does not return a result. + */ + int procedureNoResult = 1; + + /** + * The procedure returns a result. + */ + int procedureReturnsResult = 2; + + /** + * The column type is unknown. + */ + int procedureColumnUnknown = 0; + + /** + * The column type is input. + */ + int procedureColumnIn = 1; + + /** + * The column type is input/output. + */ + int procedureColumnInOut = 2; + + /** + * The column type is output + */ + int procedureColumnOut = 4; + + /** + * The column is used for return values. + */ + int procedureColumnReturn = 5; + + /** + * The column is used for storing results + */ + int procedureColumnResult = 3; + + /** + * NULL values are not allowed. + */ + int procedureNoNulls = 0; + + /** + * NULL values are allowed. + */ + int procedureNullable = 1; + + /** + * It is unknown whether or not NULL values are allowed. + */ + int procedureNullableUnknown = 2; + + /** + * The column does not allow NULL + */ + int columnNoNulls = 0; + + /** + * The column does allow NULL + */ + int columnNullable = 1; + + /** + * It is unknown whether or not the column allows NULL + */ + int columnNullableUnknown = 2; + + /** + * The best row's scope is only guaranteed to be valid so long as the + * row is actually being used. + */ + int bestRowTemporary = 0; + + /** + * The best row identifier is valid to the end of the transaction. + */ + int bestRowTransaction = 1; + + /** + * The best row identifier is valid to the end of the session. + */ + int bestRowSession = 2; + + /** + * The best row may or may not be a pseudo-column. + */ + int bestRowUnknown = 0; + + /** + * The best row identifier is not a pseudo-column. + */ + int bestRowNotPseudo = 1; + + /** + * The best row identifier is a pseudo-column. + */ + int bestRowPseudo = 2; + + /** + * It is unknown whether or not the version column is a pseudo-column. + */ + int versionColumnUnknown = 0; + + /** + * The version column is not a pseudo-column + */ + int versionColumnNotPseudo = 1; + + /** + * The version column is a pseudo-column + */ + int versionColumnPseudo = 2; + + /** + * Foreign key changes are cascaded in updates or deletes. + */ + int importedKeyCascade = 0; + + /** + * Column may not be updated or deleted in use as a foreign key. + */ + int importedKeyRestrict = 1; + + /** + * When primary key is updated or deleted, the foreign key is set to NULL. + */ + int importedKeySetNull = 2; + + /** + * If the primary key is a foreign key, it cannot be udpated or deleted. + */ + int importedKeyNoAction = 3; + + /** + * If the primary key is updated or deleted, the foreign key is set to + * a default value. + */ + int importedKeySetDefault = 4; + + /** + * Wish I knew what this meant. + */ + int importedKeyInitiallyDeferred = 5; + + /** + * Wish I knew what this meant. + */ + int importedKeyInitiallyImmediate = 6; + + /** + * Wish I knew what this meant. + */ + int importedKeyNotDeferrable = 7; + + /** + * A NULL value is not allowed for this data type. + */ + int typeNoNulls = 0; + + /** + * A NULL value is allowed for this data type. + */ + int typeNullable = 1; + + /** + * It is unknown whether or not NULL values are allowed for this data type. + */ + int typeNullableUnknown = 2; + + /** + * Where clauses are not supported for this type. + */ + int typePredNone = 0; + + /** + * Only "WHERE..LIKE" style WHERE clauses are allowed on this data type. + */ + int typePredChar = 1; + + /** + * All WHERE clauses except "WHERE..LIKE" style are allowed on this data type. + */ + int typePredBasic = 2; + + /** + * Any type of WHERE clause is allowed for this data type. + */ + int typeSearchable = 3; + + /** + * This column contains table statistics. + */ + short tableIndexStatistic = 0; + + /** + * This table index is clustered. + */ + short tableIndexClustered = 1; + + /** + * This table index is hashed. + */ + short tableIndexHashed = 2; + + /** + * This table index is of another type. + */ + short tableIndexOther = 3; + + /** + * A NULL value is not allowed for this attribute. + */ + short attributeNoNulls = 0; + + /** + * A NULL value is allowed for this attribute. + */ + short attributeNullable = 1; + + /** + * It is unknown whether or not NULL values are allowed for this attribute. + */ + short attributeNullableUnknown = 2; + + int sqlStateXOpen = 1; + + int sqlStateSQL99 = 2; + + /** + * This method tests whether or not all the procedures returned by + * the <code>getProcedures</code> method can be called by this user. + * + * @return <code>true</code> if all the procedures can be called, + * <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean allProceduresAreCallable() throws SQLException; + + /** + * This method tests whether or not all the table returned by the + * <code>getTables</code> method can be selected by this user. + * + * @return <code>true</code> if all the procedures can be called, + * <code>false</code> otherwise. + * + * @exception SQLException If an error occurs. + */ + boolean allTablesAreSelectable() throws SQLException; + + /** + * This method returns the URL for this database. + * + * @return The URL string for this database, or <code>null</code> if it + * is not known. + * @exception SQLException If an error occurs. + */ + String getURL() throws SQLException; + + /** + * This method returns the database username for this connection. + * + * @return The database username. + * @exception SQLException If an error occurs. + */ + String getUserName() throws SQLException; + + /** + * This method tests whether or not the database is in read only mode. + * + * @return <code>true</code> if the database is in read only mode, + * <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean isReadOnly() throws SQLException; + + /** + * This method tests whether or not NULL's sort as high values. + * + * @return <code>true</code> if NULL's sort as high values, <code>false</code> + * otherwise. + * @exception SQLException If an error occurs. + */ + boolean nullsAreSortedHigh() throws SQLException; + + /** + * This method tests whether or not NULL's sort as low values. + * + * @return <code>true</code> if NULL's sort as low values, <code>false</code> + * otherwise. + * @exception SQLException If an error occurs. + */ + boolean nullsAreSortedLow() throws SQLException; + + /** + * This method tests whether or not NULL's sort as high values. + * + * @return <code>true</code> if NULL's sort as high values, <code>false</code> + * otherwise. + * @exception SQLException If an error occurs. + */ + boolean nullsAreSortedAtStart() throws SQLException; + + /** + * This method test whether or not NULL's are sorted to the end + * of the list regardless of ascending or descending sort order. + * + * @return <code>true</code> if NULL's always sort to the end, + * <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean nullsAreSortedAtEnd() throws SQLException; + + /** + * This method returns the name of the database product. + * + * @return The database product. + * @exception SQLException If an error occurs. + */ + String getDatabaseProductName() throws SQLException; + + /** + * This method returns the version of the database product. + * + * @return The version of the database product. + * @exception SQLException If an error occurs. + */ + String getDatabaseProductVersion() throws SQLException; + + /** + * This method returns the name of the JDBC driver. + * + * @return The name of the JDBC driver. + * @exception SQLException If an error occurs. + */ + String getDriverName() throws SQLException; + + /** + * This method returns the version of the JDBC driver. + * + * @return The version of the JDBC driver. + * @exception SQLException If an error occurs. + */ + String getDriverVersion() throws SQLException; + + /** + * This method returns the major version number of the JDBC driver. + * + * @return The major version number of the JDBC driver. + */ + int getDriverMajorVersion(); + + /** + * This method returns the minor version number of the JDBC driver. + * + * @return The minor version number of the JDBC driver. + */ + int getDriverMinorVersion(); + + /** + * This method tests whether or not the database uses local files to + * store tables. + * + * @return <code>true</code> if the database uses local files, + * <code>false</code> otherwise. + * + * @exception SQLException If an error occurs. + */ + boolean usesLocalFiles() throws SQLException; + + /** + * This method tests whether or not the database uses a separate file for + * each table. + * + * @return <code>true</code> if the database uses a separate file for each + * table <code>false</code> otherwise. + * + * @exception SQLException If an error occurs. + */ + boolean usesLocalFilePerTable() throws SQLException; + + /** + * This method tests whether or not the database supports identifiers + * with mixed case. + * + * @return <code>true</code> if the database supports mixed case identifiers, + * <code>false</code> otherwise. + * + * @exception SQLException If an error occurs. + */ + boolean supportsMixedCaseIdentifiers() throws SQLException; + + /** + * This method tests whether or not the database treats mixed case + * identifiers as all upper case. + * + * @return <code>true</code> if the database treats all identifiers as + * upper case, <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean storesUpperCaseIdentifiers() throws SQLException; + + /** + * This method tests whether or not the database treats mixed case + * identifiers as all lower case. + * + * @return <code>true</code> if the database treats all identifiers as + * lower case, <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean storesLowerCaseIdentifiers() throws SQLException; + + /** + * This method tests whether or not the database stores mixed case + * identifers even if it treats them as case insensitive. + * + * @return <code>true</code> if the database stores mixed case identifiers, + * <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean storesMixedCaseIdentifiers() throws SQLException; + + /** + * This method tests whether or not the database supports quoted identifiers + * with mixed case. + * + * @return <code>true</code> if the database supports mixed case quoted + * identifiers, <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean supportsMixedCaseQuotedIdentifiers() throws SQLException; + + /** + * This method tests whether or not the database treats mixed case + * quoted identifiers as all upper case. + * + * @return <code>true</code> if the database treats all quoted identifiers + * as upper case, <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean storesUpperCaseQuotedIdentifiers() throws SQLException; + + /** + * This method tests whether or not the database treats mixed case + * quoted identifiers as all lower case. + * + * @return <code>true</code> if the database treats all quoted identifiers + * as lower case, <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean storesLowerCaseQuotedIdentifiers() throws SQLException; + + /** + * This method tests whether or not the database stores mixed case + * quoted identifers even if it treats them as case insensitive. + * + * @return <code>true</code> if the database stores mixed case quoted + * identifiers, <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean storesMixedCaseQuotedIdentifiers() throws SQLException; + + /** + * This metohd returns the quote string for SQL identifiers. + * + * @return The quote string for SQL identifers, or a space if quoting + * is not supported. + * @exception SQLException If an error occurs. + */ + String getIdentifierQuoteString() throws SQLException; + + /** + * This method returns a comma separated list of all the SQL keywords in + * the database that are not in SQL92. + * + * @return The list of SQL keywords not in SQL92. + * @exception SQLException If an error occurs. + */ + String getSQLKeywords() throws SQLException; + + /** + * This method returns a comma separated list of math functions. + * + * @return The list of math functions. + * @exception SQLException If an error occurs. + */ + String getNumericFunctions() throws SQLException; + + /** + * This method returns a comma separated list of string functions. + * + * @return The list of string functions. + * @exception SQLException If an error occurs. + */ + String getStringFunctions() throws SQLException; + + /** + * This method returns a comma separated list of of system functions. + * + * @return A comma separated list of system functions. + * @exception SQLException If an error occurs. + */ + String getSystemFunctions() throws SQLException; + + /** + * This method returns comma separated list of time/date functions. + * + * @return The list of time/date functions. + * @exception SQLException If an error occurs. + */ + String getTimeDateFunctions() throws SQLException; + + /** + * This method returns the string used to escape wildcards in search strings. + * + * @return The string used to escape wildcards in search strings. + * @exception SQLException If an error occurs. + */ + String getSearchStringEscape() throws SQLException; + + /** + * This methods returns non-standard characters that can appear in + * unquoted identifiers. + * + * @return Non-standard characters that can appear in unquoted identifiers. + * @exception SQLException If an error occurs. + */ + String getExtraNameCharacters() throws SQLException; + + /** + * This method tests whether or not the database supports + * "ALTER TABLE ADD COLUMN" + * + * @return <code>true</code> if column add supported, <code>false</code> + * otherwise. + * @exception SQLException If an error occurs. + */ + boolean supportsAlterTableWithAddColumn() throws SQLException; + + /** + * This method tests whether or not the database supports + * "ALTER TABLE DROP COLUMN" + * + * @return <code>true</code> if column drop supported, <code>false</code> + * otherwise. + * @exception SQLException If an error occurs. + */ + boolean supportsAlterTableWithDropColumn() throws SQLException; + + /** + * This method tests whether or not column aliasing is supported. + * + * @return <code>true</code> if column aliasing is supported, + * <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean supportsColumnAliasing() throws SQLException; + + /** + * This method tests whether the concatenation of a NULL and non-NULL + * value results in a NULL. This will always be true in fully JDBC compliant + * drivers. + * + * @return <code>true</code> if concatenating NULL and a non-NULL value + * returns a NULL, <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean nullPlusNonNullIsNull() throws SQLException; + + /** + * Tests whether or not CONVERT is supported. + * + * @return <code>true</code> if CONVERT is supported, <code>false</code> + * otherwise. + * @exception SQLException If an error occurs. + */ + boolean supportsConvert() throws SQLException; + + /** + * This method tests whether or not CONVERT can be performed between the + * specified types. The types are contants from <code>Types</code>. + * + * @param fromType The SQL type to convert from. + * @param toType The SQL type to convert to. + * @return <code>true</code> if the conversion can be performed, + * <code>false</code> otherwise. + * @see Types + */ + boolean supportsConvert(int fromType, int toType) throws + SQLException; + + /** + * This method tests whether or not table correlation names are + * supported. This will be always be <code>true</code> in a fully JDBC + * compliant driver. + * + * @return <code>true</code> if table correlation names are supported, + * <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean supportsTableCorrelationNames() throws SQLException; + + /** + * This method tests whether correlation names must be different from the + * name of the table. + * + * @return <code>true</code> if the correlation name must be different from + * the table name, <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean supportsDifferentTableCorrelationNames() throws SQLException; + + /** + * This method tests whether or not expressions are allowed in an + * ORDER BY lists. + * + * @return <code>true</code> if expressions are allowed in ORDER BY + * lists, <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean supportsExpressionsInOrderBy() throws SQLException; + + /** + * This method tests whether or ORDER BY on a non-selected column is + * allowed. + * + * @return <code>true</code> if a non-selected column can be used in an + * ORDER BY, <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean supportsOrderByUnrelated() throws SQLException; + + /** + * This method tests whether or not GROUP BY is supported. + * + * @return <code>true</code> if GROUP BY is supported, <code>false</code> + * otherwise. + * @exception SQLException If an error occurs. + */ + boolean supportsGroupBy() throws SQLException; + + /** + * This method tests whether GROUP BY on a non-selected column is + * allowed. + * + * @return <code>true</code> if a non-selected column can be used in a + * GROUP BY, <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean supportsGroupByUnrelated() throws SQLException; + + /** + * This method tests whether or not a GROUP BY can add columns not in the + * select if it includes all the columns in the select. + * + * @return <code>true</code> if GROUP BY an add columns provided it includes + * all columns in the select, <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean supportsGroupByBeyondSelect() throws SQLException; + + /** + * This method tests whether or not the escape character is supported in + * LIKE expressions. A fully JDBC compliant driver will always return + * <code>true</code>. + * + * @return <code>true</code> if escapes are supported in LIKE expressions, + * <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean supportsLikeEscapeClause() throws SQLException; + + /** + * This method tests whether multiple result sets for a single statement are + * supported. + * + * @return <code>true</code> if multiple result sets are supported for a + * single statement, <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean supportsMultipleResultSets() throws SQLException; + + /** + * This method test whether or not multiple transactions may be open + * at once, as long as they are on different connections. + * + * @return <code>true</code> if multiple transactions on different + * connections are supported, <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean supportsMultipleTransactions() throws SQLException; + + /** + * This method tests whether or not columns can be defined as NOT NULL. A + * fully JDBC compliant driver always returns <code>true</code>. + * + * @return <code>true</code> if NOT NULL columns are supported, + * <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean supportsNonNullableColumns() throws SQLException; + + /** + * This method tests whether or not the minimum grammer for ODBC is supported. + * A fully JDBC compliant driver will always return <code>true</code>. + * + * @return <code>true</code> if the ODBC minimum grammar is supported, + * <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean supportsMinimumSQLGrammar() throws SQLException; + + /** + * This method tests whether or not the core grammer for ODBC is supported. + * + * @return <code>true</code> if the ODBC core grammar is supported, + * <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean supportsCoreSQLGrammar() throws SQLException; + + /** + * This method tests whether or not the extended grammer for ODBC is supported. + * + * @return <code>true</code> if the ODBC extended grammar is supported, + * <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean supportsExtendedSQLGrammar() throws SQLException; + + /** + * This method tests whether or not the ANSI92 entry level SQL + * grammar is supported. A fully JDBC compliant drivers must return + * <code>true</code>. + * + * @return <code>true</code> if the ANSI92 entry level SQL grammar is + * supported, <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean supportsANSI92EntryLevelSQL() throws SQLException; + + /** + * This method tests whether or not the ANSI92 intermediate SQL + * grammar is supported. + * + * @return <code>true</code> if the ANSI92 intermediate SQL grammar is + * supported, <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean supportsANSI92IntermediateSQL() throws SQLException; + + /** + * This method tests whether or not the ANSI92 full SQL + * grammar is supported. + * + * @return <code>true</code> if the ANSI92 full SQL grammar is + * supported, <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean supportsANSI92FullSQL() throws SQLException; + + /** + * This method tests whether or not the SQL integrity enhancement + * facility is supported. + * + * @return <code>true</code> if the integrity enhancement facility is + * supported, <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean supportsIntegrityEnhancementFacility() throws SQLException; + + /** + * This method tests whether or not the database supports outer joins. + * + * @return <code>true</code> if outer joins are supported, <code>false</code> + * otherwise. + * @exception SQLException If an error occurs. + */ + boolean supportsOuterJoins() throws SQLException; + + /** + * This method tests whether or not the database supports full outer joins. + * + * @return <code>true</code> if full outer joins are supported, + * <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean supportsFullOuterJoins() throws SQLException; + + /** + * This method tests whether or not the database supports limited outer joins. + * + * @return <code>true</code> if limited outer joins are supported, + * <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean supportsLimitedOuterJoins() throws SQLException; + + /** + * This method returns the vendor's term for "schema". + * + * @return The vendor's term for schema. + * @exception SQLException if an error occurs. + */ + String getSchemaTerm() throws SQLException; + + /** + * This method returns the vendor's term for "procedure". + * + * @return The vendor's term for procedure. + * @exception SQLException if an error occurs. + */ + String getProcedureTerm() throws SQLException; + + /** + * This method returns the vendor's term for "catalog". + * + * @return The vendor's term for catalog. + * @exception SQLException if an error occurs. + */ + String getCatalogTerm() throws SQLException; + + /** + * This method tests whether a catalog name appears at the beginning of + * a fully qualified table name. + * + * @return <code>true</code> if the catalog name appears at the beginning, + * <code>false</code> if it appears at the end. + * @exception SQLException If an error occurs. + */ + boolean isCatalogAtStart() throws SQLException; + + /** + * This method returns the separator between the catalog name and the + * table name. + * + * @return The separator between the catalog name and the table name. + * @exception SQLException If an error occurs. + */ + String getCatalogSeparator() throws SQLException; + + /** + * This method tests whether a catalog name can appear in a data + * manipulation statement. + * + * @return <code>true</code> if a catalog name can appear in a data + * manipulation statement, <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean supportsSchemasInDataManipulation() throws SQLException; + + /** + * This method tests whether a catalog name can appear in a procedure + * call + * + * @return <code>true</code> if a catalog name can appear in a procedure + * call, <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean supportsSchemasInProcedureCalls() throws SQLException; + + /** + * This method tests whether a catalog name can appear in a table definition. + * + * @return <code>true</code> if a catalog name can appear in a table + * definition, <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean supportsSchemasInTableDefinitions() throws SQLException; + + /** + * This method tests whether a catalog name can appear in an index definition. + * + * @return <code>true</code> if a catalog name can appear in an index + * definition, <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean supportsSchemasInIndexDefinitions() throws SQLException; + + /** + * This method tests whether a catalog name can appear in privilege definitions. + * + * @return <code>true</code> if a catalog name can appear in privilege + * definition, <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean supportsSchemasInPrivilegeDefinitions() throws SQLException; + + /** + * This method tests whether a catalog name can appear in a data + * manipulation statement. + * + * @return <code>true</code> if a catalog name can appear in a data + * manipulation statement, <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean supportsCatalogsInDataManipulation() throws SQLException; + + /** + * This method tests whether a catalog name can appear in a procedure + * call + * + * @return <code>true</code> if a catalog name can appear in a procedure + * call, <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean supportsCatalogsInProcedureCalls() throws SQLException; + + /** + * This method tests whether a catalog name can appear in a table definition. + * + * @return <code>true</code> if a catalog name can appear in a table + * definition, <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean supportsCatalogsInTableDefinitions() throws SQLException; + + /** + * This method tests whether a catalog name can appear in an index definition. + * + * @return <code>true</code> if a catalog name can appear in an index + * definition, <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean supportsCatalogsInIndexDefinitions() throws SQLException; + + /** + * This method tests whether a catalog name can appear in privilege definitions. + * + * @return <code>true</code> if a catalog name can appear in privilege + * definition, <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean supportsCatalogsInPrivilegeDefinitions() throws SQLException; + + /** + * This method tests whether or not that database supports positioned + * deletes. + * + * @return <code>true</code> if positioned deletes are supported, + * <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean supportsPositionedDelete() throws SQLException; + + /** + * This method tests whether or not that database supports positioned + * updates. + * + * @return <code>true</code> if positioned updates are supported, + * <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean supportsPositionedUpdate() throws SQLException; + + /** + * This method tests whether or not SELECT FOR UPDATE is supported by the + * database. + * + * @return <code>true</code> if SELECT FOR UPDATE is supported + * <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean supportsSelectForUpdate() throws SQLException; + + /** + * This method tests whether or not stored procedures are supported on + * this database. + * + * @return <code>true</code> if stored procedures are supported, + * <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean supportsStoredProcedures() throws SQLException; + + /** + * This method tests whether or not subqueries are allowed in comparisons. + * A fully JDBC compliant driver will always return <code>true</code>. + * + * @return <code>true</code> if subqueries are allowed in comparisons, + * <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean supportsSubqueriesInComparisons() throws SQLException; + + /** + * This method tests whether or not subqueries are allowed in exists + * expressions. A fully JDBC compliant driver will always return + * <code>true</code>. + * + * @return <code>true</code> if subqueries are allowed in exists + * expressions, <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean supportsSubqueriesInExists() throws SQLException; + + /** + * This method tests whether subqueries are allowed in IN statements. + * A fully JDBC compliant driver will always return <code>true</code>. + * + * @return <code>true</code> if the driver supports subqueries in IN + * statements, <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean supportsSubqueriesInIns() throws SQLException; + + /** + * This method tests whether or not subqueries are allowed in quantified + * expressions. A fully JDBC compliant driver will always return + * <code>true</code>. + * + * @return <code>true</code> if subqueries are allowed in quantified + * expressions, <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean supportsSubqueriesInQuantifieds() throws SQLException; + + /** + * This method test whether or not correlated subqueries are allowed. A + * fully JDBC compliant driver will always return <code>true</code>. + * + * @return <code>true</code> if correlated subqueries are allowed, + * <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean supportsCorrelatedSubqueries() throws SQLException; + + /** + * This method tests whether or not the UNION statement is supported. + * + * @return <code>true</code> if UNION is supported, <code>false</code> + * otherwise. + * @exception SQLException If an error occurs. + */ + boolean supportsUnion() throws SQLException; + + /** + * This method tests whether or not the UNION ALL statement is supported. + * + * @return <code>true</code> if UNION ALL is supported, <code>false</code> + * otherwise. + * @exception SQLException If an error occurs. + */ + boolean supportsUnionAll() throws SQLException; + + /** + * This method tests whether or not the database supports cursors + * remaining open across commits. + * + * @return <code>true</code> if cursors can remain open across commits, + * <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean supportsOpenCursorsAcrossCommit() throws SQLException; + + /** + * This method tests whether or not the database supports cursors + * remaining open across rollbacks. + * + * @return <code>true</code> if cursors can remain open across rollbacks, + * <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean supportsOpenCursorsAcrossRollback() throws SQLException; + + /** + * This method tests whether or not the database supports statements + * remaining open across commits. + * + * @return <code>true</code> if statements can remain open across commits, + * <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean supportsOpenStatementsAcrossCommit() throws SQLException; + + /** + * This method tests whether or not the database supports statements + * remaining open across rollbacks. + * + * @return <code>true</code> if statements can remain open across rollbacks, + * <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean supportsOpenStatementsAcrossRollback() throws SQLException; + + /** + * This method returns the number of hex characters allowed in an inline + * binary literal. + * + * @return The number of hex characters allowed in a binary literal, 0 meaning + * either an unknown or unlimited number. + * @exception SQLException If an error occurs. + */ + int getMaxBinaryLiteralLength() throws SQLException; + + /** + * This method returns the maximum length of a character literal. + * + * @return The maximum length of a character literal. + * @exception SQLException If an error occurs. + */ + int getMaxCharLiteralLength() throws SQLException; + + /** + * This method returns the maximum length of a column name. + * + * @return The maximum length of a column name. + * @exception SQLException If an error occurs. + */ + int getMaxColumnNameLength() throws SQLException; + + /** + * This method returns the maximum number of columns in a GROUP BY statement. + * + * @return The maximum number of columns in a GROUP BY statement. + * @exception SQLException If an error occurs. + */ + int getMaxColumnsInGroupBy() throws SQLException; + + /** + * This method returns the maximum number of columns in an index. + * + * @return The maximum number of columns in an index. + * @exception SQLException If an error occurs. + */ + int getMaxColumnsInIndex() throws SQLException; + + /** + * This method returns the maximum number of columns in an ORDER BY statement. + * + * @return The maximum number of columns in an ORDER BY statement. + * @exception SQLException If an error occurs. + */ + int getMaxColumnsInOrderBy() throws SQLException; + + /** + * This method returns the maximum number of columns in a SELECT statement. + * + * @return The maximum number of columns in a SELECT statement. + * @exception SQLException If an error occurs. + */ + int getMaxColumnsInSelect() throws SQLException; + + /** + * This method returns the maximum number of columns in a table. + * + * @return The maximum number of columns in a table. + * @exception SQLException If an error occurs. + */ + int getMaxColumnsInTable() throws SQLException; + + /** + * This method returns the maximum number of connections this client + * can have to the database. + * + * @return The maximum number of database connections. + * @SQLException If an error occurs. + */ + int getMaxConnections() throws SQLException; + + /** + * This method returns the maximum length of a cursor name. + * + * @return The maximum length of a cursor name. + * @exception SQLException If an error occurs. + */ + int getMaxCursorNameLength() throws SQLException; + + /** + * This method returns the maximum length of an index. + * + * @return The maximum length of an index. + * @exception SQLException If an error occurs. + */ + int getMaxIndexLength() throws SQLException; + + /** + * This method returns the maximum length of a schema name. + * + * @return The maximum length of a schema name. + * @exception SQLException If an error occurs. + */ + int getMaxSchemaNameLength() throws SQLException; + + /** + * This method returns the maximum length of a procedure name. + * + * @return The maximum length of a procedure name. + * @exception SQLException If an error occurs. + */ + int getMaxProcedureNameLength() throws SQLException; + + /** + * This method returns the maximum length of a catalog name. + * + * @return The maximum length of a catalog name. + * @exception SQLException If an error occurs. + */ + int getMaxCatalogNameLength() throws SQLException; + + /** + * This method returns the maximum size of a row in bytes. + * + * @return The maximum size of a row. + * @exception SQLException If an error occurs. + */ + int getMaxRowSize() throws SQLException; + + /** + * This method tests whether or not the maximum row size includes BLOB's + * + * @return <code>true</code> if the maximum row size includes BLOB's, + * <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean doesMaxRowSizeIncludeBlobs() throws SQLException; + + /** + * This method includes the maximum length of a SQL statement. + * + * @return The maximum length of a SQL statement. + * @exception SQLException If an error occurs. + */ + int getMaxStatementLength() throws SQLException; + + /** + * This method returns the maximum number of statements that can be + * active at any time. + * + * @return The maximum number of statements that can be active at any time. + * @exception SQLException If an error occurs. + */ + int getMaxStatements() throws SQLException; + + /** + * This method returns the maximum length of a table name. + * + * @return The maximum length of a table name. + * @exception SQLException If an error occurs. + */ + int getMaxTableNameLength() throws SQLException; + + /** + * This method returns the maximum number of tables that may be referenced + * in a SELECT statement. + * + * @return The maximum number of tables allowed in a SELECT statement. + * @exception SQLException If an error occurs. + */ + int getMaxTablesInSelect() throws SQLException; + + /** + * This method returns the maximum length of a user name. + * + * @return The maximum length of a user name. + * @exception SQLException If an error occurs. + */ + int getMaxUserNameLength() throws SQLException; + + /** + * This method returns the default transaction isolation level of the + * database. + * + * @return The default transaction isolation level of the database. + * @exception SQLException If an error occurs. + * @see Connection + */ + int getDefaultTransactionIsolation() throws SQLException; + + /** + * This method tests whether or not the database supports transactions. + * + * @return <code>true</code> if the database supports transactions, + * <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean supportsTransactions() throws SQLException; + + /** + * This method tests whether or not the database supports the specified + * transaction isolation level. + * + * @param level The transaction isolation level. + * + * @return <code>true</code> if the specified transaction isolation level + * is supported, <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean supportsTransactionIsolationLevel(int level) throws + SQLException; + + /** + * This method tests whether or not DDL and DML statements allowed within + * the same transaction. + * + * @return <code>true</code> if DDL and DML statements are allowed in the + * same transaction, <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean supportsDataDefinitionAndDataManipulationTransactions() + throws SQLException; + + /** + * This method tests whether or not only DML statement are allowed + * inside a transaction. + * + * @return <code>true</code> if only DML statements are allowed in + * transactions, <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean supportsDataManipulationTransactionsOnly() throws + SQLException; + + /** + * This method tests whether or not a DDL statement will cause the + * current transaction to be automatically committed. + * + * @return <code>true</code> if DDL causes an immediate transaction commit, + * <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean dataDefinitionCausesTransactionCommit() throws SQLException; + + /** + * This method tests whether or not DDL statements are ignored in + * transactions. + * + * @return <code>true</code> if DDL statements are ignored in transactions, + * <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean dataDefinitionIgnoredInTransactions() throws SQLException; + + /** + * This method returns a list of all the stored procedures matching the + * specified pattern in the given schema and catalog. This is returned + * a <code>ResultSet</code> with the following columns: + * <p> + * <ol> + * <li>PROCEDURE_CAT - The catalog the procedure is in, which may be + * <code>null</code>.</li> + * <li>PROCEDURE_SCHEM - The schema the procedures is in, which may be + * <code>null</code>.</li> + * <li>PROCEDURE_NAME - The name of the procedure.</li> + * <li>Unused</li> + * <li>Unused</li> + * <li>Unused</li> + * <li>REMARKS - A description of the procedure</li> + * <li>PROCEDURE_TYPE - Indicates the return type of the procedure, which + * is one of the contstants defined in this class + * (<code>procedureResultUnknown</code>, <code>procedureNoResult</code>, or + * <code>procedureReturnsResult</code>).</li> + * </ol> + * + * @param catalog The name of the catalog to return stored procedured from, + * or "" to return procedures from all catalogs. + * @param schemaPattern A schema pattern for the schemas to return stored + * procedures from, or "" to return procedures from all schemas. + * @param procedurePattern The pattern of procedure names to return. + * @returns A <code>ResultSet</code> with all the requested procedures. + * @exception SQLException If an error occurs. + */ + ResultSet getProcedures(String catalog, String schemaPattern, String + procedurePattern) throws SQLException; + + /** + * This method returns a list of the parameter and result columns for + * the requested stored procedures. This is returned in the form of a + * <code>ResultSet</code> with the following columns: + * <p> + * <ol> + * <li>PROCEDURE_CAT - The catalog the procedure is in, which may be + * <code>null</code>.</li> + * <li>PROCEDURE_SCHEM - The schema the procedures is in, which may be + * <code>null</code>.</li> + * <li>PROCEDURE_NAME - The name of the procedure.</li> + * <li>COLUMN_NAME - The name of the column</li> + * <li>COLUMN_TYPE - The type of the column, which will be one of the + * contants defined in this class (<code>procedureColumnUnknown</code>, + * <code>procedureColumnIn</code>, <code>procedureColumnInOut</code>, + * <code>procedureColumnOut</code>, <code>procedureColumnReturn</code>, + * or <code>procedureColumnResult</code>).</li> + * <li>DATA_TYPE - The SQL type of the column. This is one of the constants + * defined in <code>Types</code>.</li> + * <li>TYPE_NAME - The string name of the data type for this column.</li> + * <li>PRECISION - The precision of the column.</li> + * <li>LENGTH - The length of the column in bytes</li> + * <li>SCALE - The scale of the column.</li> + * <li>RADIX - The radix of the column.</li> + * <li>NULLABLE - Whether or not the column is NULLABLE. This is one of + * the constants defined in this class (<code>procedureNoNulls</code>, + * <code>procedureNullable</code>, or <code>procedureNullableUnknown</code>)</li> + * <li>REMARKS - A description of the column.</li> + * </ol> + * + * @param catalog The name of the catalog to return stored procedured from, + * or "" to return procedures from all catalogs. + * @param schemaPattern A schema pattern for the schemas to return stored + * procedures from, or "" to return procedures from all schemas. + * @param procedurePattern The pattern of procedures names to return. + * @param columnPattern The pattern of column names to return. + * @returns A <code>ResultSet</code> with all the requested procedures. + * @exception SQLException If an error occurs. + */ + ResultSet getProcedureColumns(String catalog, String schemaPattern, + String procedurePattern, String columnPattern) throws + SQLException; + + /** + * This method returns a list of the requested table as a + * <code>ResultSet</code> with the following columns: + * + * <ol> + * <li>TABLE_CAT - The catalog the table is in, which may be <code>null</code>.</li> + * <li>TABLE_SCHEM - The schema the table is in, which may be <code>null</code>.</li> + * <li>TABLE_NAME - The name of the table.</li> + * <li>TABLE_TYPE - A string describing the table type. This will be one + * of the values returned by the <code>getTableTypes()</code> method.</li> + * <li>REMARKS - Comments about the table.</li> + * </ol> + * + * @param catalog The name of the catalog to return tables from, + * or "" to return tables from all catalogs. + * @param schemaPattern A schema pattern for the schemas to return tables + * from, or "" to return tables from all schemas. + * @param tablePattern The pattern of table names to return. + * @param types The list of table types to include; null returns all types. + * @returns A <code>ResultSet</code> with all the requested tables. + * @exception SQLException If an error occurs. + */ + ResultSet getTables(String catalog, String schemaPattern, String + tablePattern, String[] types) throws SQLException; + + /** + * This method returns the list of database schemas as a + * <code>ResultSet</code>, with one column - TABLE_SCHEM - that is the + * name of the schema. + * + * @return A <code>ResultSet</code> with all the requested schemas. + * @exception SQLException If an error occurs. + */ + ResultSet getSchemas() throws SQLException; + + /** + * This method returns the list of database catalogs as a + * <code>ResultSet</code> with one column - TABLE_CAT - that is the + * name of the catalog. + * + * @return A <code>ResultSet</code> with all the requested catalogs. + * @exception SQLException If an error occurs. + */ + ResultSet getCatalogs() throws SQLException; + + /** + * This method returns the list of database table types as a + * <code>ResultSet</code> with one column - TABLE_TYPE - that is the + * name of the table type. + * + * @return A <code>ResultSet</code> with all the requested table types. + * @exception SQLException If an error occurs. + */ + ResultSet getTableTypes() throws SQLException; + + /** + * This method returns a list of the tables columns for + * the requested tables. This is returned in the form of a + * <code>ResultSet</code> with the following columns: + * <p> + * <ol> + * <li>TABLE_CAT - The catalog the table is in, which may be + * <code>null</code>.</li> + * <li>TABLE_SCHEM - The schema the tables is in, which may be + * <code>null</code>.</li> + * <li>TABLE_NAME - The name of the table.</li> + * <li>COLUMN_NAME - The name of the column</li> + * <li>DATA_TYPE - The SQL type of the column. This is one of the constants + * defined in <code>Types</code>.</li> + * <li>TYPE_NAME - The string name of the data type for this column.</li> + * <li>COLUMN_SIZE - The size of the column.</li> + * <li>Unused</li> + * <li>NUM_PREC_RADIX - The radix of the column.</li> + * <li>NULLABLE - Whether or not the column is NULLABLE. This is one of + * the constants defined in this class (<code>tableNoNulls</code>, + * <code>tableNullable</code>, or <code>tableNullableUnknown</code>)</li> + * <li>REMARKS - A description of the column.</li> + * <li>COLUMN_DEF - The default value for the column, may be <code>null</code>.</li> + * <li>SQL_DATA_TYPE - Unused</li> + * <li>SQL_DATETIME_SUB - Unused</li> + * <li>CHAR_OCTET_LENGTH - For character columns, the maximum number of bytes + * in the column.</li> + * <li>ORDINAL_POSITION - The index of the column in the table.</li> + * <li>IS_NULLABLE - "NO" means no, "YES" means maybe, and an empty string + * means unknown.</li> + * </ol> + * + * @param catalog The name of the catalog to return table from, + * or "" to return tables from all catalogs. + * @param schemaPattern A schema pattern for the schemas to return + * tables from, or "" to return tables from all schemas. + * @param tablePattern The pattern of table names to return. + * @param columnPattern The pattern of column names to return. + * @returns A <code>ResultSet</code> with all the requested tables. + * @exception SQLException If an error occurs. + */ + ResultSet getColumns(String catalog, String schemaPattern, String + tablePattern, String columnPattern) throws SQLException; + + /** + * This method returns the access rights that have been granted to the + * requested columns. This information is returned as a <code>ResultSet</code> + * with the following columns: + * + * <ol> + * <li>TABLE_CAT - The catalog the table is in, which may be + * <code>null</code>.</li> + * <li>TABLE_SCHEM - The schema the tables is in, which may be + * <code>null</code>.</li> + * <li>TABLE_NAME - The name of the table.</li> + * <li>COLUMN_NAME - The name of the column.</li> + * <li>GRANTOR - The entity that granted the access.</li> + * <li>GRANTEE - The entity granted the access.</li> + * <li>PRIVILEGE - The name of the privilege granted.</li> + * <li>IS_GRANTABLE - "YES" if the grantee can grant the privilege to + * others, "NO" if not, and <code>null</code> if unknown.</li> + * </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 tableName The table name to return information for. + * @param columnPattern A pattern of column names to return information for. + * @return A <code>ResultSet</code> with all the requested privileges. + * @exception SQLException If an error occurs. + */ + ResultSet getColumnPrivileges(String catalog, String schema, String + tableName, String columnPattern) throws SQLException; + + /** + * This method returns the access rights that have been granted to the + * requested tables. This information is returned as a <code>ResultSet</code> + * with the following columns: + * + * <ol> + * <li>TABLE_CAT - The catalog the table is in, which may be + * <code>null</code>.</li> + * <li>TABLE_SCHEM - The schema the tables is in, which may be + * <code>null</code>.</li> + * <li>TABLE_NAME - The name of the table.</li> + * <li>GRANTOR - The entity that granted the access.</li> + * <li>GRANTEE - The entity granted the access.</li> + * <li>PRIVILEGE - The name of the privilege granted.</li> + * <li>IS_GRANTABLE - "YES" if the grantee can grant the privilege to + * others, "NO" if not, and <code>null</code> if unknown.</li> + * </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 schemaPattern The schema to retrieve information from, or the empty string + * to return entities not associated with a schema. + * @param tablePattern The table name pattern of tables to return + * information for. + * @return A <code>ResultSet</code> with all the requested privileges. + * @exception SQLException If an error occurs. + */ + ResultSet getTablePrivileges(String catalog, String schemaPattern, + String tablePattern) throws SQLException; + + /** + * This method returns the best set of columns for uniquely identifying + * a row. It returns this information as a <code>ResultSet</code> with + * the following columns: + * + * <ol> + * <li>SCOPE - The scope of the results returned. This is one of the + * constants defined in this class (<code>bestRowTemporary</code>, + * <code>bestRowTransaction</code>, or <code>bestRowSession</code>).</li> + * <li>COLUMN_NAME - The name of the column.</li> + * <li>DATA_TYPE - The SQL type of the column. This is one of the constants + * defined in <code>Types</code>.</li> + * <li>TYPE_NAME - The string name of the data type for this column.</li> + * <li>COLUMN_SIZE - The precision of the columns</li> + * <li>BUFFER_LENGTH - Unused</li> + * <li>DECIMAL_DIGITS - The scale of the column.</li> + * <li>PSEUDO_COLUMN - Whether or not the best row identifier is a + * pseudo_column. This is one of the constants defined in this class + * (<code>bestRowUnknown</code>, <code>bestRowNotPseudo</code>, or + * <code>bestRowPseudo</code>).</li> + * </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 tableName The table name to return information for. + * @param scope One of the best row id scope constants from this class. + * @param nullable <code>true</code> to include columns that are nullable, + * <code>false</code> otherwise. + * @return A <code>ResultSet</code> with the best row identifier. + * @exception SQLException If an error occurs. + */ + ResultSet getBestRowIdentifier(String catalog, String schema, + String tableName, int scope, boolean nullable) throws SQLException; + + /** + * This method returns the set of columns that are automatically updated + * when the row is update. It returns this information as a + * <code>ResultSet</code> with the following columns: + * + * <ol> + * <li>SCOPE - Unused</li> + * <li>COLUMN_NAME - The name of the column.</li> + * <li>DATA_TYPE - The SQL type of the column. This is one of the constants + * defined in <code>Types</code>.</li> + * <li>TYPE_NAME - The string name of the data type for this column.</li> + * <li>COLUMN_SIZE - The precision of the columns</li> + * <li>BUFFER_LENGTH - Unused</li> + * <li>DECIMAL_DIGITS - The scale of the column.</li> + * <li>PSEUDO_COLUMN - Whether or not the best row identifier is a + * pseudo_column. This is one of the constants defined in this class + * (<code>versionRowUnknown</code>, <code>versionRowNotPseudo</code>, or + * <code>versionRowPseudo</code>).</li> + * </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 tableName The table name to return information for + * @return A <code>ResultSet</code> with the version columns. + * @exception SQLException If an error occurs. + */ + ResultSet getVersionColumns(String catalog, String schema, + String tableName) throws SQLException; + + /** + * This method returns a list of a table's primary key columns. These + * are returned as a <code>ResultSet</code> with the following columns. + * + * <ol> + * <li>TABLE_CAT - The catalog of the table, which may be <code>null</code>.</li> + * <li>TABLE_SCHEM - The schema of the table, which may be <code>null</code>.</li> + * <li>TABLE_NAME - The name of the table.</li> + * <li>COLUMN_NAME - The name of the column.</li> + * <li>KEY_SEQ - The sequence number of the column within the primary key.</li> + * <li>PK_NAME - The name of the primary key, which may be <code>null</code>.</li> + * </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 tableName The table name to return information for. + * @return A <code>ResultSet</code> with the primary key columns. + * @exception SQLException If an error occurs. + */ + ResultSet getPrimaryKeys(String catalog, String schema, String tableName) + throws SQLException; + + /** + * This method returns a list of the table's foreign keys. These are + * returned as a <code>ResultSet</code> with the following columns: + * + * <ol> + * <li>PKTABLE_CAT - The catalog of the table the key was imported from.</li> + * <li>PKTABLE_SCHEM - The schema of the table the key was imported from.</li> + * <li>PKTABLE_NAME - The name of the table the key was imported from.</li> + * <li>PKCOLUMN_NAME - The name of the column that was imported.</li> + * <li>FKTABLE_CAT - The foreign key catalog name.</li> + * <li>FKTABLE_SCHEM - The foreign key schema name.</li> + * <li>FKTABLE_NAME - The foreign key table name.</li> + * <li>FKCOLUMN_NAME - The foreign key column name.</li> + * <li>KEY_SEQ - The sequence number of the column within the foreign key.</li> + * <li>UPDATE_RULE - How the foreign key behaves when the primary key is + * updated. This is one of the constants defined in this class + * (<code>importedNoAction</code>, <code>importedKeyCascade</code>, + * <code>importedKeySetNull</code>, <code>importedKeySetDefault</code>, or + * <code>importedKeyRestrict</code>).</li> + * <li>DELETE_RULE - How the foreign key behaves when the primary key is + * deleted. This is one of the constants defined in this class + * (<code>importedNoAction</code>, <code>importedKeyCascade</code>, + * <code>importedKeySetNull</code>, or <code>importedKeySetDefault</code>)</li> + * <li>FK_NAME - The name of the foreign key.</li> + * <li>PK_NAME - The name of the primary key.</li> + * <li>DEFERRABILITY - The deferrability value. This is one of the + * constants defined in this table (<code>importedKeyInitiallyDeferred</code>, + * <code>importedKeyInitiallyImmediate</code>, or + * <code>importedKeyNotDeferrable</code>).</li> + * </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 tableName The table name to return information for. + * @return A <code>ResultSet</code> with the foreign key columns. + * @exception SQLException If an error occurs. + */ + ResultSet getImportedKeys(String catalog, String schema, + String tableName) throws SQLException; + + /** + * This method returns a list of the table's which use this table's + * primary key as a foreign key. The information is + * returned as a <code>ResultSet</code> with the following columns: + * + * <ol> + * <li>PKTABLE_CAT - The catalog of the table the key was imported from.</li> + * <li>PKTABLE_SCHEM - The schema of the table the key was imported from.</li> + * <li>PKTABLE_NAME - The name of the table the key was imported from.</li> + * <li>PKCOLUMN_NAME - The name of the column that was imported.</li> + * <li>FKTABLE_CAT - The foreign key catalog name.</li> + * <li>FKTABLE_SCHEM - The foreign key schema name.</li> + * <li>FKTABLE_NAME - The foreign key table name.</li> + * <li>FKCOLUMN_NAME - The foreign key column name.</li> + * <li>KEY_SEQ - The sequence number of the column within the foreign key.</li> + * <li>UPDATE_RULE - How the foreign key behaves when the primary key is + * updated. This is one of the constants defined in this class + * (<code>importedNoAction</code>, <code>importedKeyCascade</code>, + * <code>importedKeySetNull</code>, <code>importedKeySetDefault</code>, or + * <code>importedKeyRestrict</code>).</li> + * <li>DELETE_RULE - How the foreign key behaves when the primary key is + * deleted. This is one of the constants defined in this class + * (<code>importedNoAction</code>, <code>importedKeyCascade</code>, + * <code>importedKeySetNull</code>, or <code>importedKeySetDefault</code>)</li> + * <li>FK_NAME - The name of the foreign key.</li> + * <li>PK_NAME - The name of the primary key.</li> + * <li>DEFERRABILITY - The deferrability value. This is one of the + * constants defined in this table (<code>importedKeyInitiallyDeferred</code>, + * <code>importedKeyInitiallyImmediate</code>, or + * <code>importedKeyNotDeferrable</code>).</li> + * </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 tableName The table name to return information for. + * @return A <code>ResultSet</code> with the requested information + * @exception SQLException If an error occurs. + */ + ResultSet getExportedKeys(String catalog, String schema, + String tableName) throws SQLException; + + /** + * This method returns a description of how one table imports another + * table's primary key as a foreign key. The information is + * returned as a <code>ResultSet</code> with the following columns: + * + * <ol> + * <li>PKTABLE_CAT - The catalog of the table the key was imported from.</li> + * <li>PKTABLE_SCHEM - The schema of the table the key was imported from.</li> + * <li>PKTABLE_NAME - The name of the table the key was imported from.</li> + * <li>PKCOLUMN_NAME - The name of the column that was imported.</li> + * <li>FKTABLE_CAT - The foreign key catalog name.</li> + * <li>FKTABLE_SCHEM - The foreign key schema name.</li> + * <li>FKTABLE_NAME - The foreign key table name.</li> + * <li>FKCOLUMN_NAME - The foreign key column name.</li> + * <li>KEY_SEQ - The sequence number of the column within the foreign key.</li> + * <li>UPDATE_RULE - How the foreign key behaves when the primary key is + * updated. This is one of the constants defined in this class + * (<code>importedNoAction</code>, <code>importedKeyCascade</code>, + * <code>importedKeySetNull</code>, <code>importedKeySetDefault</code>, or + * <code>importedKeyRestrict</code>).</li> + * <li>DELETE_RULE - How the foreign key behaves when the primary key is + * deleted. This is one of the constants defined in this class + * (<code>importedNoAction</code>, <code>importedKeyCascade</code>, + * <code>importedKeySetNull</code>, or <code>importedKeySetDefault</code>)</li> + * <li>FK_NAME - The name of the foreign key.</li> + * <li>PK_NAME - The name of the primary key.</li> + * <li>DEFERRABILITY - The deferrability value. This is one of the + * constants defined in this table (<code>importedKeyInitiallyDeferred</code>, + * <code>importedKeyInitiallyImmediate</code>, or + * <code>importedKeyNotDeferrable</code>).</li> + * </ol> + * + * @param primaryCatalog 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, on the + * exporting side. + * @param primarySchema The schema to retrieve information from, or the empty + * string to return entities not associated with a schema, on the + * exporting side. + * @param primaryTableName The table name to return information for, on the + * exporting side. + * @param foreignCatalog 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, on + * the importing side. + * @param foreignSchema The schema to retrieve information from, or the + * empty string to return entities not associated with a schema on + * the importing side. + * @param foreignTableName The table name to return information for on the + * importing side. + * @return A <code>ResultSet</code> with the requested information + * @exception SQLException If an error occurs. + */ + ResultSet getCrossReference(String primaryCatalog, String + primarySchema, String primaryTableName, String foreignCatalog, String + foreignSchema, String foreignTableName) throws SQLException; + + /** + * This method returns a list of the SQL types supported by this + * database. The information is returned as a <code>ResultSet</code> + * with the following columns: + * + * <ol> + * <li>TYPE_NAME - The name of the data type.</li> + * <li>DATA_TYPE - A data type constant from <code>Types</code> for this + * type.</li> + * <li>PRECISION - The maximum precision of this type.</li> + * <li>LITERAL_PREFIX - Prefix value used to quote a literal, which may be + * <code>null</code>.</li> + * <li>LITERAL_SUFFIX - Suffix value used to quote a literal, which may be + * <code>null</code>.</li> + * <li>CREATE_PARAMS - The parameters used to create the type, which may be + * <code>null</code>.</li> + * <li>NULLABLE - Whether or not this type supports NULL values. This will + * be one of the constants defined in this interface + * (<code>typeNoNulls</code>, <code>typeNullable</code>, or + * <code>typeNullableUnknown</code>).</li> + * <li>CASE_SENSITIVE - Whether or not the value is case sensitive.</li> + * <li>SEARCHABLE - Whether or not "LIKE" expressions are supported in + * WHERE clauses for this type. This will be one of the constants defined + * in this interface (<code>typePredNone</code>, <code>typePredChar</code>, + * <code>typePredBasic</code>, or <code>typeSearchable</code>).</li> + * <li>UNSIGNED_ATTRIBUTE - Is the value of this type unsigned.</li> + * <li>FIXED_PREC_SCALE - Whether or not this type can be used for money.</li> + * <li>AUTO_INCREMENT - Whether or not this type supports auto-incrementing.</li> + * <li>LOCAL_TYPE_NAME - A localized name for this data type.</li> + * <li>MINIMUM_SCALE - The minimum scale supported by this type.</li> + * <li>MAXIMUM_SCALE - The maximum scale supported by this type.</li> + * <li>SQL_DATA_TYPE - Unused.</li> + * <li>SQL_DATETIME_SUB - Unused.</li> + * <li>NUM_PREC_RADIX - The radix of this data type.</li> + * </ol> + * + * @return A <code>ResultSet</code> with the list of available data types. + * @exception SQLException If an error occurs. + */ + ResultSet getTypeInfo() throws SQLException; + + /** + * This method returns information about a tables indices and statistics. + * It is returned as a <code>ResultSet</code> with the following columns: + * + * <ol> + * <li>TABLE_CAT - The catalog of the table, which may be <code>null</code>.</li> + * <li>TABLE_SCHEM - The schema of the table, which may be <code>null</code>.</li> + * <li>TABLE_NAME - The name of the table.</li> + * <li>NON_UNIQUE - Are index values non-unique?</li> + * <li>INDEX_QUALIFIER The index catalog, which may be <code>null</code></li> + * <li>INDEX_NAME - The name of the index.</li> + * <li>TYPE - The type of index, which will be one of the constants defined + * in this interface (<code>tableIndexStatistic</code>, + * <code>tableIndexClustered</code>, <code>tableIndexHashed</code>, or + * <code>tableIndexOther</code>).</li> + * <li>ORDINAL_POSITION - The sequence number of this column in the index. + * This will be 0 when the index type is <code>tableIndexStatistic</code>.</li> + * <li>COLUMN_NAME - The name of this column in the index.</li> + * <li>ASC_OR_DESC - "A" for an ascending sort sequence, "D" for a + * descending sort sequence or <code>null</code> if a sort sequence is not + * supported.</li> + * <li>CARDINALITY - The number of unique rows in the index, or the number + * of rows in the table if the index type is <code>tableIndexStatistic</code>.</li> + * <li>PAGES - The number of pages used for the index, or the number of pages + * in the table if the index type is <code>tableIndexStatistic</code>.</li> + * <li>FILTER_CONDITION - The filter condition for this index, which may be + * <code>null</code>.</li> + * </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 tableName The table name to return information for. + * @param unique <code>true</code> to return only unique indexes, + * <code>false</code> otherwise. + * @param approximate <code>true</code> if data values can be approximations, + * <code>false</code> otherwise. + * @return A <code>ResultSet</code> with the requested index information + * @exception SQLException If an error occurs. + */ + ResultSet getIndexInfo(String catalog, String schema, String tableName, + boolean unique, boolean approximate) 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 + */ + 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 concurrency 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 + */ + boolean supportsResultSetConcurrency(int type, int concurrency) + 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 + */ + 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 + */ + 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 + */ + 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 + */ + 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 + */ + 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 + */ + 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 + */ + 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 + */ + 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 + */ + 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. + */ + 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: + * + * <ol> + * <li>TYPE_CAT - The catalog name, which may be <code>null</code>.</li> + * <li>TYPE_SCEHM - The schema name, which may be <code>null</code>.</li> + * <li>TYPE_NAME - The user defined data type name.</li> + * <li>CLASS_NAME - The Java class name this type maps to.</li> + * <li>DATA_TYPE - A type identifier from <code>Types</code> for this type. + * This will be one of <code>JAVA_OBJECT</code>, <code>STRUCT</code>, or + * <code>DISTINCT</code>.</li> + * <li>REMARKS - Comments about this data type.</li> + * </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 schemaPattern 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 identifier patterns (from <code>Types</code>) to + * match. + * @return A <code>ResultSet</code> with the requested type information + * @exception SQLException If an error occurs. + */ + ResultSet getUDTs(String catalog, String schemaPattern, 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. + */ + Connection getConnection() throws SQLException; + + /** + * This method tests whether the databse supports savepoints. + * + * @return <code>true</code> if the database supports savepoints, + * <code>false</code> if it does not. + * @exception SQLException If an error occurs. + * @see Savepoint + * @since 1.4 + */ + boolean supportsSavepoints() throws SQLException; + + /** + * This method tests whether the database supports named parameters. + * + * @return <code>true</code> if the database supports named parameters, + * <code>false</code> if it does not. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + boolean supportsNamedParameters() throws SQLException; + + /** + * This method tests whether the database supports returning multiple + * <code>ResultSet</code>S from a <code>CallableStatement</code> at once. + * + * @return <code>true</code> if the database supports returnig multiple + * results at once, <code>false</code> if it does not. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + boolean supportsMultipleOpenResults() throws SQLException; + + /** + * @since 1.4 + */ + boolean supportsGetGeneratedKeys() throws SQLException; + + /** + * @since 1.4 + */ + ResultSet getSuperTypes(String catalog, String schemaPattern, + String typePattern) throws SQLException; + + /** + * @since 1.4 + */ + ResultSet getSuperTables(String catalog, String schemaPattern, + String tablePattern) throws SQLException; + + /** + * @since 1.4 + */ + ResultSet getAttributes(String catalog, String schemaPattern, String + typePattern, String attributePattern) throws SQLException; + + /** + * This method tests if the database supports the specified holdability type. + * Valid values for this parameter are specified in the + * <code>ResultSet</code> class. + * + * @param holdability The holdability type to test. + * @return <code>true</code> if the database supports the holdability type, + * <code>false</code> if it does not. + * @exception SQLException If an error occurs. + * @see ResultSet + * @since 1.4 + */ + boolean supportsResultSetHoldability(int holdability) + throws SQLException; + + /** + * This method returns the default holdability type of <code>ResultSet</code>S + * retrieved from this database. The possible values are specified in the + * <code>ResultSet</code> class. + * + * @return The default holdability type. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + int getResultSetHoldability() throws SQLException; + + /** + * This method returns the major version number of the database. + * + * @return The major version number of the database. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + int getDatabaseMajorVersion() throws SQLException; + + /** + * This method returns the minor version number of the database. + * + * @return The minor version number of the database. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + int getDatabaseMinorVersion() throws SQLException; + + /** + * This method returns the major version number of the JDBC driver. + * + * @return The major version number of the JDBC driver. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + int getJDBCMajorVersion() throws SQLException; + + /** + * This method returns the minor version number of the JDBC driver. + * + * @return The minor version number of the database. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + int getJDBCMinorVersion() throws SQLException; + + /** + * @since 1.4 + */ + int getSQLStateType() throws SQLException; + + /** + * @since 1.4 + */ + boolean locatorsUpdateCopy() throws SQLException; + + /** + * @since 1.4 + */ + boolean supportsStatementPooling() throws SQLException; +} diff --git a/libjava/classpath/java/sql/Date.java b/libjava/classpath/java/sql/Date.java new file mode 100644 index 000000000..f5eea1a2d --- /dev/null +++ b/libjava/classpath/java/sql/Date.java @@ -0,0 +1,184 @@ +/* Date.java -- Wrapper around java.util.Date + Copyright (C) 1999, 2000, 2003, 2005, 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package java.sql; + +import java.text.ParseException; +import java.text.SimpleDateFormat; + +/** + * This class is a wrapper around java.util.Date to allow the JDBC + * driver to identify the value as a SQL Date. + * + * @author Aaron M. Renn (arenn@urbanophile.com) + */ +public class Date extends java.util.Date +{ + static final long serialVersionUID = 1511598038487230103L; + + /** + * Used for parsing and formatting this date. + */ + private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + + /** + * This method initializes a new instance of this class with the + * specified year, month, and day. + * + * @param year The year of this date minue 1900. + * @param month The month of this date (0-11). + * @param day The day of this date (1-31). + * + * @deprecated + */ + public Date(int year, int month, int day) + { + super(year, month, day); + } + + /** + * This method initializes a new instance of this class with the + * specified time value representing the number of milliseconds since + * Jan 1, 1970 at 12:00 midnight GMT. + * + * @param date The time value to intialize this date to. + */ + public Date(long date) + { + super(date); + } + + /** + * This method always throws an IllegalArgumentException. + * + * @throws IllegalArgumentException when it's called. + * @deprecated + */ + public int getHours() throws IllegalArgumentException + { + throw new IllegalArgumentException(); + } + + /** + * This method always throws an IllegalArgumentException. + * + * @throws IllegalArgumentException when it's called. + * @deprecated + */ + public int getMinutes() throws IllegalArgumentException + { + throw new IllegalArgumentException(); + } + + /** + * This method always throws an IllegalArgumentException. + * + * @throws IllegalArgumentException when it's called. + * @deprecated + */ + public int getSeconds() throws IllegalArgumentException + { + throw new IllegalArgumentException(); + } + + /** + * This method always throws an IllegalArgumentException. + * + * @throws IllegalArgumentException when it's called. + * @deprecated + */ + public void setHours(int newValue) throws IllegalArgumentException + { + throw new IllegalArgumentException(); + } + + /** + * This method always throws an IllegalArgumentException. + * + * @throws IllegalArgumentException when it's called. + * @deprecated + */ + public void setMinutes(int newValue) throws IllegalArgumentException + { + throw new IllegalArgumentException(); + } + + /** + * This method always throws an IllegalArgumentException. + * + * @throws IllegalArgumentException when it's called. + * @deprecated + */ + public void setSeconds(int newValue) throws IllegalArgumentException + { + throw new IllegalArgumentException(); + } + + /** + * This method returns a new instance of this class by parsing a + * date in JDBC format into a Java date. + * + * @param str The string to parse. + * @return The resulting <code>java.sql.Date</code> value. + */ + public static Date valueOf (String str) + { + try + { + java.util.Date d = (java.util.Date) sdf.parseObject(str); + + if (d == null) + throw new IllegalArgumentException(str); + else + return new Date(d.getTime()); + } + catch (ParseException e) + { + throw new IllegalArgumentException(str); + } + } + + /** + * This method returns this date in JDBC format. + * + * @return This date as a string. + */ + public String toString() + { + return sdf.format(this); + } +} diff --git a/libjava/classpath/java/sql/Driver.java b/libjava/classpath/java/sql/Driver.java new file mode 100644 index 000000000..d7b2e8a17 --- /dev/null +++ b/libjava/classpath/java/sql/Driver.java @@ -0,0 +1,123 @@ +/* Driver.java -- A JDBC driver + Copyright (C) 1999, 2000, 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package java.sql; + +import java.util.Properties; + +/** + * This interface specifies a mechanism for accessing a JDBC database + * driver. When the class implementing this method is loaded, it should + * register an instance of itself with the <code>DriverManager</code> in + * a static initializer. + * <p> + * Because the <code>DriverManager</code> might attempt to use several + * drivers to find one that can connect to the requested database, + * this driver should not cause large numbers of classes and code to + * be loaded. If another driver is the one that ends up performing the + * request, any loading done by this driver would be wasted. + * + * @author Aaron M. Renn (arenn@urbanophile.com) + */ +public interface Driver +{ + /** + * This method connects to the specified database using the connection + * properties supplied. If the driver does not understand the database + * URL, it should return <code>null</code> instead of throwing an + * exception since the <code>DriverManager</code> will probe a driver + * in this manner. + * + * @param url The URL string for this connection. + * @param properties The list of database connection properties. + * @return A <code>Connection</code> object for the newly established + * connection, or <code>null</code> if the URL is not understood. + * @exception SQLException If an error occurs. + */ + Connection connect(String url, Properties properties) throws SQLException; + + /** + * This method tests whether or not the driver believes it can connect to + * the specified database. The driver should only test whether it + * understands and accepts the URL. It should not necessarily attempt to + * probe the database for a connection. + * + * @param url The database URL string. + * @return <code>true</code> if the drivers can connect to the database, + * <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean acceptsURL(String url) throws SQLException; + + /** + * This method returns an array of possible properties that could be + * used to connect to the specified database. + * + * @param url The URL string of the database to connect to. + * @param properties The list of properties the caller is planning to use + * to connect to the database. + * @return A list of possible additional properties for a connection to this + * database. This list may be empty. + * @exception SQLException If an error occurs. + */ + DriverPropertyInfo[] getPropertyInfo(String url, Properties properties) + throws SQLException; + + /** + * This method returns the major version number of the driver. + * + * @return The major version number of the driver. + */ + int getMajorVersion(); + + /** + * This method returns the minor version number of the driver. + * + * @return The minor version number of the driver. + */ + int getMinorVersion(); + + /** + * This method tests whether or not the driver is JDBC compliant. This + * method should only return <code>true</code> if the driver has been + * certified as JDBC compliant. + * + * @return <code>true</code> if the driver has been certified JDBC compliant, + * <code>false</code> otherwise. + */ + boolean jdbcCompliant(); +} diff --git a/libjava/classpath/java/sql/DriverManager.java b/libjava/classpath/java/sql/DriverManager.java new file mode 100644 index 000000000..86ed02930 --- /dev/null +++ b/libjava/classpath/java/sql/DriverManager.java @@ -0,0 +1,345 @@ +/* DriverManager.java -- Manage JDBC drivers + Copyright (C) 1999, 2000, 2001, 2003, 2004, 2006 + 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., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package java.sql; + +import java.io.PrintStream; +import java.io.PrintWriter; +import java.util.Enumeration; +import java.util.Properties; +import java.util.StringTokenizer; +import java.util.Vector; + +/** + * This class manages the JDBC drivers in the system. It maintains a + * registry of drivers and locates the appropriate driver to handle a + * JDBC database URL. + * <p> + * On startup, <code>DriverManager</code> loads all the managers specified + * by the system property <code>jdbc.drivers</code>. The value of this + * property should be a colon separated list of fully qualified driver + * class names. Additional drivers can be loaded at any time by + * simply loading the driver class with <code>class.forName(String)</code>. + * The driver should automatically register itself in a static + * initializer. + * <p> + * The methods in this class are all <code>static</code>. This class + * cannot be instantiated. + * + * @author Aaron M. Renn (arenn@urbanophile.com) + */ +public class DriverManager +{ + /** + * This is the log stream for JDBC drivers. + */ + private static PrintStream log_stream; + + /** + * This is the log writer for JDBC drivers. + */ + private static PrintWriter log_writer; + + /** + * This is the login timeout used by JDBC drivers. + */ + private static int login_timeout; + + /** + * This is the list of JDBC drivers that are loaded. + */ + private static Vector drivers; + // Hmm, seems like we might want to do a Hashtable and lookup by something, + // but what would it be? + + // Load all drivers on startup + static + { + drivers = new Vector(); + + String driver_string = System.getProperty("jdbc.drivers"); + if (driver_string != null) + { + StringTokenizer st = new StringTokenizer(driver_string); + while (st.hasMoreTokens()) + { + String driver_classname = st.nextToken(); + + try + { + Class.forName(driver_classname); // The driver registers itself + } + catch (Exception e) + { + // Ignore not founds + } + } + } + + } + + /** Can't be instantiated. */ + private DriverManager() + { + } + + /** + * 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 out The new log writer for JDBC. + */ + public static void setLogWriter(PrintWriter out) + { + DriverManager.log_writer = out; + } + +/** + * This method attempts to return a connection to the specified + * JDBC URL string using the specified connection properties. + * + * @param url The JDBC URL string to connect to. + * @param properties The connection properties. + * + * @return A <code>Connection</code> to that URL. + * + * @exception SQLException If an error occurs. + */ + public static Connection getConnection(String url, Properties properties) + throws SQLException + { + Driver d = getDriver(url); + if (d == null) + throw new SQLException("Driver not found for URL: " + url); + + return d.connect(url, properties); + } + + + /** + * This method attempts to return a connection to the specified + * JDBC URL string using the specified username and password. + * + * @param url The JDBC URL string to connect to. + * @param user The username to connect with. + * @param password The password to connect with. + * @return A <code>Connection</code> to that URL. + * @exception SQLException If an error occurs. + */ + public static Connection getConnection(String url, String user, + String password) throws SQLException + { + Properties p = new Properties(); + + if (user != null) + p.setProperty("user", user); + if (password != null) + p.setProperty("password", password); + + return getConnection(url, p); + } + + /** + * This method attempts to return a connection to the specified + * JDBC URL string. + * + * @param url The JDBC URL string to connect to. + * + * @return A <code>Connection</code> to that URL. + * + * @exception SQLException If an error occurs. + */ + public static Connection getConnection(String url) throws SQLException + { + return getConnection(url, new Properties()); + } + + /** + * This method returns a driver that can connect to the specified + * JDBC URL string. This will be selected from among drivers loaded + * at initialization time and those drivers manually loaded by the + * same class loader as the caller. + * + * @param url The JDBC URL string to find a driver for. + * + * @return A <code>Driver</code> that can connect to the specified + * URL. + * + * @exception SQLException If an error occurs, or no suitable driver can be found. + */ + public static Driver getDriver(String url) throws SQLException + { + // FIXME: Limit driver search to the appropriate subset of loaded drivers. + Enumeration e = drivers.elements(); + while(e.hasMoreElements()) + { + Driver d = (Driver)e.nextElement(); + if (d.acceptsURL(url)) + return d; + } + + throw new SQLException("No driver found for " + url); + } + + /** + * This method registers a new driver with the manager. This is normally + * 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) throws SQLException + { + if (! drivers.contains(driver)) + drivers.addElement(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) throws SQLException + { + if (drivers.contains(driver)) + drivers.removeElement(driver); + } + + /** + * 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<Driver> getDrivers() + { + Vector v = new Vector(); + Enumeration e = drivers.elements(); + + // Is this right? + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + + while(e.hasMoreElements()) + { + Object obj = e.nextElement(); + + ClassLoader loader = obj.getClass().getClassLoader(); + + if (loader == null) + loader = ClassLoader.getSystemClassLoader(); + if (! loader.equals(cl)) + continue; + + v.addElement(obj); + } + + return v.elements(); + } + + /** + * This method set the login timeout used by JDBC drivers. This is a + * system-wide parameter that applies to all drivers. + * + * @param seconds The new login timeout value. + */ + public static void setLoginTimeout(int seconds) + { + DriverManager.login_timeout = seconds; + } + + /** + * This method returns the login timeout in use by JDBC drivers systemwide. + * + * @return The login timeout. + */ + public static int getLoginTimeout() + { + return login_timeout; + } + + /** + * This method sets the log stream in use by JDBC. + * + * @param stream The log stream in use by JDBC. + * @deprecated Use <code>setLogWriter</code> instead. + */ + public static void setLogStream(PrintStream stream) + { + DriverManager.log_stream = stream; + } + + /** + * This method returns the log stream in use by JDBC. + * + * @return The log stream in use by JDBC. + * @deprecated Use <code>getLogWriter()</code> instead. + */ + public static PrintStream getLogStream() + { + return log_stream; + } + + /** + * This method prints the specified line to the log stream. + * + * @param message The string to write to the log stream. + */ + public static void println(String message) + { + if (log_stream != null) // Watch for user not using logging + log_stream.println(message); + } +} diff --git a/libjava/classpath/java/sql/DriverPropertyInfo.java b/libjava/classpath/java/sql/DriverPropertyInfo.java new file mode 100644 index 000000000..c191fa5ef --- /dev/null +++ b/libjava/classpath/java/sql/DriverPropertyInfo.java @@ -0,0 +1,88 @@ +/* DriverPropertyInfo.java -- Property information about drivers. + Copyright (C) 1999 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., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package java.sql; + +/** + * This class holds a driver property that can be used for querying or + * setting driver configuration parameters. + * + * @author Aaron M. Renn (arenn@urbanophile.com) + */ +public class DriverPropertyInfo +{ + /** + * The name of the property. + */ + public String name; + + /** + * A description of the property, possibly <code>null</code>. + */ + public String description; + + /** + * A flag indicating whether or not a value for this property is required + * in order to connect to the database. + */ + public boolean required; + + /** + * This is the value of the property. + */ + public String value; + + /** + * If values are restricted to certain choices, this is the list of valid + * ones. Otherwise it is <code>null</code>. + */ + public String[] choices; + + /** + * This method initializes a new instance of <code>DriverPropertyInfo</code> + * with the specified name and value. All other fields are defaulted. + * + * @param name The name of the property. + * @param value The value to assign to the property. + */ + public DriverPropertyInfo(String name, String value) + { + this.name = name; + this.value = value; + } +} diff --git a/libjava/classpath/java/sql/ParameterMetaData.java b/libjava/classpath/java/sql/ParameterMetaData.java new file mode 100644 index 000000000..722d78bec --- /dev/null +++ b/libjava/classpath/java/sql/ParameterMetaData.java @@ -0,0 +1,103 @@ +/* ParameterMetaData.java + Copyright (C) 2002 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., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package java.sql; + +/** + * @since 1.4 + */ +public interface ParameterMetaData +{ + int parameterNoNulls = 0; + + int parameterNullable = 1; + + int parameterNullableUnknown = 2; + + int parameterModeUnknown = 0; + + int parameterModeIn = 1; + + int parameterModeInOut = 2; + + int parameterModeOut = 4; + + /** + * @since 1.4 + */ + int getParameterCount() throws SQLException; + + /** + * @since 1.4 + */ + int isNullable(int param) throws SQLException; + + /** + * @since 1.4 + */ + boolean isSigned(int param) throws SQLException; + + /** + * @since 1.4 + */ + int getPrecision(int param) throws SQLException; + + /** + * @since 1.4 + */ + int getScale(int param) throws SQLException; + + /** + * @since 1.4 + */ + int getParameterType(int param) throws SQLException; + + /** + * @since 1.4 + */ + String getParameterTypeName(int param) throws SQLException; + + /** + * @since 1.4 + */ + String getParameterClassName(int param) throws SQLException; + + /** + * @since 1.4 + */ + int getParameterMode(int param) throws SQLException; +} diff --git a/libjava/classpath/java/sql/PreparedStatement.java b/libjava/classpath/java/sql/PreparedStatement.java new file mode 100644 index 000000000..4490b5bab --- /dev/null +++ b/libjava/classpath/java/sql/PreparedStatement.java @@ -0,0 +1,458 @@ +/* PreparedStatement.java -- Interface for pre-compiled statements. + Copyright (C) 1999, 2000, 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package java.sql; + +import java.io.InputStream; +import java.io.Reader; +import java.math.BigDecimal; +import java.net.URL; +import java.util.Calendar; + +/** + * This interface provides a mechanism for executing pre-compiled + * statements. This provides greater efficiency when calling the same + * statement multiple times. Parameters are allowed in a statement, + * providings for maximum reusability. + * + * <p> Note that in this class parameter indices start at 1, not 0.</p> + * + * @author Aaron M. Renn (arenn@urbanophile.com) + */ +public interface PreparedStatement extends Statement +{ + /** + * This method executes a prepared SQL query and returns its ResultSet. + * + * @return The ResultSet of the SQL statement. + * @exception SQLException If an error occurs. + */ + ResultSet executeQuery() throws SQLException; + + /** + * This method executes an SQL INSERT, UPDATE or DELETE statement. SQL + * statements that return nothing such as SQL DDL statements can be executed. + * + * @return The result is either the row count for INSERT, UPDATE or DELETE + * statements; or 0 for SQL statements that return nothing. + * @exception SQLException If an error occurs. + */ + int executeUpdate() 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 sqlType The SQL type identifier of the parameter from + * <code>Types</code> + * + * @exception SQLException If an error occurs. + */ + void setNull(int index, int sqlType) throws SQLException; + + /** + * This method sets the specified parameter from the given Java + * <code>boolean</code> value. + * + * @param index The index of the parameter value to set. + * @param value The value of the parameter. + * @exception SQLException If an error occurs. + */ + void setBoolean(int index, boolean value) throws SQLException; + + /** + * This method sets the specified parameter from the given Java + * <code>byte</code> value. + * + * @param index The index of the parameter value to set. + * @param value The value of the parameter. + * @exception SQLException If an error occurs. + */ + void setByte(int index, byte value) throws SQLException; + + /** + * This method sets the specified parameter from the given Java + * <code>short</code> value. + * + * @param index The index of the parameter value to set. + * @param value The value of the parameter. + * @exception SQLException If an error occurs. + */ + void setShort(int index, short value) throws SQLException; + + /** + * This method sets the specified parameter from the given Java + * <code>int</code> value. + * + * @param index The index of the parameter value to set. + * @param value The value of the parameter. + * @exception SQLException If an error occurs. + */ + void setInt(int index, int value) throws SQLException; + + /** + * This method sets the specified parameter from the given Java + * <code>long</code> value. + * + * @param index The index of the parameter value to set. + * @param value The value of the parameter. + * @exception SQLException If an error occurs. + */ + void setLong(int index, long value) throws SQLException; + + /** + * This method sets the specified parameter from the given Java + * <code>float</code> value. + * + * @param index The index of the parameter value to set. + * @param value The value of the parameter. + * @exception SQLException If an error occurs. + */ + void setFloat(int index, float value) throws SQLException; + + /** + * This method sets the specified parameter from the given Java + * <code>double</code> value. + * + * @param index The index of the parameter value to set. + * @param value The value of the parameter. + * @exception SQLException If an error occurs. + */ + void setDouble(int index, double value) throws SQLException; + + /** + * This method sets the specified parameter from the given Java + * <code>java.math.BigDecimal</code> value. + * + * @param index The index of the parameter value to set. + * @param value The value of the parameter. + * @exception SQLException If an error occurs. + */ + void setBigDecimal(int index, BigDecimal value) throws + SQLException; + + /** + * This method sets the specified parameter from the given Java + * <code>String</code> value. + * + * @param index The index of the parameter value to set. + * @param value The value of the parameter. + * @exception SQLException If an error occurs. + */ + void setString(int index, String value) throws SQLException; + + /** + * This method sets the specified parameter from the given Java + * <code>byte</code> array value. + * + * @param index The index of the parameter value to set. + * @param value The value of the parameter. + * @exception SQLException If an error occurs. + */ + void setBytes(int index, byte[] 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. + * @exception SQLException If an error occurs. + */ + void setDate(int index, Date 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. + * @exception SQLException If an error occurs. + */ + void setTime(int index, Time 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. + * @exception SQLException If an error occurs. + */ + void setTimestamp(int index, Timestamp value) + 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. + * @param stream The stream from which the parameter value is read. + * @param count The number of bytes in the stream. + * @exception SQLException If an error occurs. + */ + void setAsciiStream(int index, InputStream stream, int count) + throws SQLException; + + /** + * This method sets the specified parameter from the given Java + * Unicode UTF-8 <code>InputStream</code> value. + * + * @param index The index of the parameter value to set. + * @param stream The stream from which the parameter value is read. + * @param count The number of bytes in the stream. + * @exception SQLException If an error occurs. + * @deprecated + */ + void setUnicodeStream(int index, InputStream stream, int count) + throws SQLException; + + /** + * This method sets the specified parameter from the given Java + * binary <code>InputStream</code> value. + * + * @param index The index of the parameter value to set. + * @param stream The stream from which the parameter value is read. + * @param count The number of bytes in the stream. + * @exception SQLException If an error occurs. + */ + void setBinaryStream(int index, InputStream stream, int count) + throws SQLException; + + /** + * This method clears all of the input parameter that have been + * set on this statement. + * + * @exception SQLException If an error occurs. + */ + void clearParameters() throws SQLException; + + /** + * This method sets the specified parameter from the given Java + * <code>Object</code> value. The specified SQL object type will be used. + * + * @param index The index of the parameter value to set. + * @param value The value of the parameter. + * @param sqlType The SQL type to use for the parameter, from + * <code>Types</code> + * @param scale The scale of the value, for numeric values only. + * @exception SQLException If an error occurs. + * @see Types + */ + void setObject(int index, Object value, int sqlType, int scale) + throws SQLException; + + /** + * This method sets the specified parameter from the given Java + * <code>Object</code> value. The specified SQL object type will be used. + * + * @param index The index of the parameter value to set. + * @param value The value of the parameter. + * @param sqlType The SQL type to use for the parameter, from + * <code>Types</code> + * @exception SQLException If an error occurs. + * @see Types + */ + void setObject(int index, Object value, int sqlType) + 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. + * + * @param index The index of the parameter value to set. + * @param value The value of the parameter. + * @exception SQLException If an error occurs. + */ + void setObject(int index, Object value) 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 + * statements handled by executeQuery and executeUpdate. + * + * @return The result of the SQL statement. + * @exception SQLException If an error occurs. + */ + boolean execute() throws SQLException; + + /** + * This method adds a set of parameters to the batch for JDBC 2.0. + * @exception SQLException If an error occurs. + */ + void addBatch() 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 reader The reader from which the parameter value is read. + * @param count The number of characters in the stream. + * @exception SQLException If an error occurs. + */ + void setCharacterStream(int index, Reader reader, int count) + 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 <code>Ref</code> used to set the value of the parameter. + * @exception SQLException If an error occurs. + */ + 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 <code>Blob</code> used to set the + * value of the parameter. + * @exception SQLException If an error occurs. + */ + 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 <code>Clob</code> used to set the + * value of the parameter. + * @exception SQLException If an error occurs. + */ + 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. + */ + void setArray(int index, Array value) 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. + */ + ResultSetMetaData getMetaData() 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 cal The <code>Calendar</code> to use for timezone and locale. + * @exception SQLException If an error occurs. + */ + void setDate(int index, Date value, Calendar cal) + 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 cal The <code>Calendar</code> to use for timezone and locale. + * @exception SQLException If an error occurs. + */ + void setTime(int index, Time value, Calendar cal) + 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 cal The <code>Calendar</code> to use for timezone and locale. + * @exception SQLException If an error occurs. + */ + void setTimestamp(int index, Timestamp value, Calendar cal) + 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 sqlType The SQL type identifier of the parameter from + * <code>Types</code> + * @param typeName The name of the data type, for user defined types. + * @exception SQLException If an error occurs. + */ + void setNull(int index, int sqlType, String typeName) + throws SQLException; + + /** + * This method sets the specified parameter from the given Java + * <code>java.net.URL</code> value. + * + * @param index The index of the parameter to set. + * @param value The value of the parameter. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + void setURL(int index, URL value) throws SQLException; + + /** + * Returns information about the parameters set on this + * <code>PreparedStatement</code> (see {@link ParameterMetaData} for a + * detailed description of the provided information). + * + * @return Meta data for the parameters of this statement. + * @see ParameterMetaData + * @since 1.4 + */ + ParameterMetaData getParameterMetaData() throws SQLException; +} diff --git a/libjava/classpath/java/sql/Ref.java b/libjava/classpath/java/sql/Ref.java new file mode 100644 index 000000000..f37c8fe4d --- /dev/null +++ b/libjava/classpath/java/sql/Ref.java @@ -0,0 +1,75 @@ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package java.sql; + +import java.util.Map; + +/** + * This interface provides a mechanism for obtaining information about + * a SQL structured type + * + * @author Aaron M. Renn (arenn@urbanophile.com) + * @since 1.2 + */ +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. + * @since 1.2 + */ + String getBaseTypeName() throws SQLException; + + /** + * @since 1.4 + */ + Object getObject(Map<String, Class<?>> map) throws SQLException; + + /** + * @since 1.4 + */ + Object getObject() throws SQLException; + + /** + * @since 1.4 + */ + void setObject(Object value) throws SQLException; +} diff --git a/libjava/classpath/java/sql/ResultSet.java b/libjava/classpath/java/sql/ResultSet.java new file mode 100644 index 000000000..3b49a6a0d --- /dev/null +++ b/libjava/classpath/java/sql/ResultSet.java @@ -0,0 +1,1612 @@ +/* ResultSet.java -- A SQL statement result set. + Copyright (C) 1999, 2000, 2002, 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package java.sql; + +import java.io.InputStream; +import java.io.Reader; +import java.math.BigDecimal; +import java.net.URL; +import java.util.Calendar; +import java.util.Map; + +/** + * This interface provides access to the data set returned by a SQL + * statement. An instance of this interface is returned by the various + * execution methods in the <code>Statement</code>. + * + * <p> This class models a cursor, which can be stepped through one row at a + * time. Methods are provided for accessing columns by column name or by + * index.</p> + * + * <p> Note that a result set is invalidated if the statement that returned + * it is closed.</p> + * + * @author Aaron M. Renn (arenn@urbanophile.com) + */ +public interface ResultSet +{ + /** + * The rows will be processed in order from first to last. + */ + int FETCH_FORWARD = 1000; + + /** + * The rows will be processed in order from last to first. + */ + int FETCH_REVERSE = 1001; + + /** + * The rows will be processed in an unknown order + */ + int FETCH_UNKNOWN = 1002; + + /** + * This type of result set may only step forward through the rows returned. + */ + int TYPE_FORWARD_ONLY = 1003; + + /** + * This type of result set is scrollable and is not sensitive to changes + * made by other statements. + */ + int TYPE_SCROLL_INSENSITIVE = 1004; + + /** + * This type of result set is scrollable and is also sensitive to changes + * made by other statements. + */ + int TYPE_SCROLL_SENSITIVE = 1005; + + /** + * The concurrency mode of for the result set may not be modified. + */ + int CONCUR_READ_ONLY = 1007; + + /** + * The concurrency mode of for the result set may be modified. + */ + int CONCUR_UPDATABLE = 1008; + + int HOLD_CURSORS_OVER_COMMIT = 1; + + int CLOSE_CURSORS_AT_COMMIT = 2; + + /** + * This method advances to the next row in the result set. Any streams + * open on the current row are closed automatically. + * + * @return <code>true</code> if the next row exists, <code>false</code> + * otherwise. + * @exception SQLException If an error occurs. + */ + boolean next() throws SQLException; + + /** + * This method closes the result set and frees any associated resources. + * + * @exception SQLException If an error occurs. + */ + void close() throws SQLException; + + /** + * This method tests whether the value of the last column that was fetched + * was actually a SQL NULL value. + * + * @return <code>true</code> if the last column fetched was a NULL, + * <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean wasNull() throws SQLException; + + /** + * This method returns the value of the specified column as a Java + * <code>String</code>. + * + * @param columnIndex The index of the column to return. + * @return The column value as a <code>String</code>. + * @exception SQLException If an error occurs. + */ + String getString(int columnIndex) throws SQLException; + + /** + * This method returns the value of the specified column as a Java + * <code>boolean</code>. + * + * @param columnIndex The index of the column to return. + * @return The column value as a <code>boolean</code>. + * @exception SQLException If an error occurs. + */ + boolean getBoolean(int columnIndex) throws SQLException; + + /** + * This method returns the value of the specified column as a Java + * <code>byte</code>. + * + * @param columnIndex The index of the column to return. + * @return The column value as a <code>byte</code>. + * @exception SQLException If an error occurs. + */ + byte getByte(int columnIndex) throws SQLException; + + /** + * This method returns the value of the specified column as a Java + * <code>short</code>. + * + * @param columnIndex The index of the column to return. + * @return The column value as a <code>short</code>. + * @exception SQLException If an error occurs. + */ + short getShort(int columnIndex) throws SQLException; + + /** + * This method returns the value of the specified column as a Java + * <code>int</code>. + * + * @param columnIndex The index of the column to return. + * @return The column value as a <code>int</code>. + * @exception SQLException If an error occurs. + */ + int getInt(int columnIndex) throws SQLException; + + /** + * This method returns the value of the specified column as a Java + * <code>long</code>. + * + * @param columnIndex The index of the column to return. + * @return The column value as a <code>long</code>. + * @exception SQLException If an error occurs. + */ + long getLong(int columnIndex) throws SQLException; + + /** + * This method returns the value of the specified column as a Java + * <code>float</code>. + * + * @param columnIndex The index of the column to return. + * @return The column value as a <code>float</code>. + * @exception SQLException If an error occurs. + */ + float getFloat(int columnIndex) throws SQLException; + + /** + * This method returns the value of the specified column as a Java + * <code>double</code>. + * + * @param columnIndex The index of the column to return. + * @return The column value as a <code>double</code>. + * @exception SQLException If an error occurs. + */ + double getDouble(int columnIndex) throws SQLException; + + /** + * This method returns the value of the specified column as a Java + * <code>BigDecimal</code>. + * + * @param columnIndex 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>. + * @exception SQLException If an error occurs. + * @deprecated + */ + BigDecimal getBigDecimal(int columnIndex, int scale) + throws SQLException; + + /** + * This method returns the value of the specified column as a Java + * byte array. + * + * @param columnIndex The index of the column to return. + * @return The column value as a byte array + * @exception SQLException If an error occurs. + */ + byte[] getBytes(int columnIndex) throws SQLException; + + /** + * This method returns the value of the specified column as a Java + * <code>java.sql.Date</code>. + * + * @param columnIndex The index of the column to return. + * @return The column value as a <code>java.sql.Date</code>. + * @exception SQLException If an error occurs. + */ + Date getDate(int columnIndex) throws SQLException; + + /** + * This method returns the value of the specified column as a Java + * <code>java.sql.Time</code>. + * + * @param columnIndex The index of the column to return. + * @return The column value as a <code>java.sql.Time</code>. + * @exception SQLException If an error occurs. + */ + Time getTime(int columnIndex) throws SQLException; + + /** + * This method returns the value of the specified column as a Java + * <code>java.sql.Timestamp</code>. + * + * @param columnIndex The index of the column to return. + * @return The column value as a <code>java.sql.Timestamp</code>. + * @exception SQLException If an error occurs. + */ + Timestamp getTimestamp(int columnIndex) throws SQLException; + + /** + * This method returns the value of the specified column as an ASCII + * 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 columnIndex The index of the column to return. + * @return The column value as an ASCII <code>InputStream</code>. + * @exception SQLException If an error occurs. + */ + InputStream getAsciiStream(int columnIndex) throws SQLException; + + /** + * This method returns the value of the specified column as a Unicode UTF-8 + * 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 columnIndex The index of the column to return. + * @return The column value as a Unicode UTF-8 <code>InputStream</code>. + * @exception SQLException If an error occurs. + * @deprecated Use getCharacterStream instead. + */ + InputStream getUnicodeStream(int columnIndex) throws SQLException; + + /** + * This method returns the value of the specified column as a raw byte + * 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 columnIndex The index of the column to return. + * @return The column value as a raw byte <code>InputStream</code>. + * @exception SQLException If an error occurs. + */ + InputStream getBinaryStream(int columnIndex) throws SQLException; + + /** + * This method returns the value of the specified column as a Java + * <code>String</code>. + * + * @param columnName The name of the column to return. + * @return The column value as a <code>String</code>. + * @exception SQLException If an error occurs. + */ + String getString(String columnName) throws SQLException; + + /** + * This method returns the value of the specified column as a Java + * <code>boolean</code>. + * + * @param columnName The name of the column to return. + * @return The column value as a <code>boolean</code>. + * @exception SQLException If an error occurs. + */ + boolean getBoolean(String columnName) throws SQLException; + + /** + * This method returns the value of the specified column as a Java + * <code>byte</code>. + * + * @param columnName The name of the column to return. + * @return The column value as a <code>byte</code>. + * @exception SQLException If an error occurs. + */ + byte getByte(String columnName) throws SQLException; + + /** + * This method returns the value of the specified column as a Java + * <code>short</code>. + * + * @param columnName The name of the column to return. + * @return The column value as a <code>short</code>. + * @exception SQLException If an error occurs. + */ + short getShort(String columnName) throws SQLException; + + /** + * This method returns the value of the specified column as a Java + * <code>int</code>. + * + * @param columnName The name of the column to return. + * @return The column value as a <code>int</code>. + * @exception SQLException If an error occurs. + */ + int getInt(String columnName) throws SQLException; + + /** + * This method returns the value of the specified column as a Java + * <code>long</code>. + * + * @param columnName The name of the column to return. + * @return The column value as a <code>long</code>. + * @exception SQLException If an error occurs. + */ + long getLong(String columnName) throws SQLException; + + /** + * This method returns the value of the specified column as a Java + * <code>float</code>. + * + * @param columnName The name of the column to return. + * @return The column value as a <code>float</code>. + * @exception SQLException If an error occurs. + */ + float getFloat(String columnName) throws SQLException; + + /** + * This method returns the value of the specified column as a Java + * <code>double</code>. + * + * @param columnName The name of the column to return. + * @return The column value as a <code>double</code>. + * @exception SQLException If an error occurs. + */ + double getDouble(String columnName) throws SQLException; + + /** + * This method returns the value of the specified column as a Java + * <code>BigDecimal</code>. + * + * @param columnName The name of the column to return. + * @return The column value as a <code>BigDecimal</code>. + * @exception SQLException If an error occurs. + * @deprecated + */ + BigDecimal getBigDecimal(String columnName, int scale) + throws SQLException; + + /** + * This method returns the value of the specified column as a Java + * byte array. + * + * @param columnName The name of the column to return. + * @return The column value as a byte array + * @exception SQLException If an error occurs. + */ + byte[] getBytes(String columnName) throws SQLException; + + /** + * This method returns the value of the specified column as a Java + * <code>java.sql.Date</code>. + * + * @param columnName The name of the column to return. + * @return The column value as a <code>java.sql.Date</code>. + * @exception SQLException If an error occurs. + */ + Date getDate(String columnName) throws SQLException; + + /** + * This method returns the value of the specified column as a Java + * <code>java.sql.Time</code>. + * + * @param columnName The name of the column to return. + * @return The column value as a <code>java.sql.Time</code>. + * @exception SQLException If an error occurs. + */ + Time getTime(String columnName) throws SQLException; + + /** + * This method returns the value of the specified column as a Java + * <code>java.sql.Timestamp</code>. + * + * @param columnName The name of the column to return. + * @return The column value as a <code>java.sql.Timestamp</code>. + * @exception SQLException If an error occurs. + */ + Timestamp getTimestamp(String columnName) throws SQLException; + + /** + * This method returns the value of the specified column as an ASCII + * 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 columnName The name of the column to return. + * @return The column value as an ASCII <code>InputStream</code>. + * @exception SQLException If an error occurs. + */ + InputStream getAsciiStream(String columnName) throws SQLException; + + /** + * This method returns the value of the specified column as a Unicode UTF-8 + * 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 columnName The name of the column to return. + * @return The column value as a Unicode UTF-8 <code>InputStream</code>. + * @exception SQLException If an error occurs. + * @deprecated Use getCharacterStream instead. + */ + InputStream getUnicodeStream(String columnName) throws SQLException; + + /** + * This method returns the value of the specified column as a raw byte + * 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 columnName The name of the column to return. + * @return The column value as a raw byte <code>InputStream</code>. + * @exception SQLException If an error occurs. + */ + InputStream getBinaryStream(String columnName) throws SQLException; + + /** + * This method returns the first SQL warning associated with this result + * set. Any additional warnings will be chained to this one. + * + * @return The first SQLWarning for this result set, or <code>null</code> if + * there are no warnings. + * @exception SQLException If an error occurs. + */ + SQLWarning getWarnings() throws SQLException; + + /** + * This method clears all warnings associated with this result set. + * + * @exception SQLException If an error occurs. + */ + void clearWarnings() throws SQLException; + + /** + * This method returns the name of the database cursor used by this + * result set. + * + * @return The name of the database cursor used by this result set. + * @exception SQLException If an error occurs. + */ + String getCursorName() throws SQLException; + + /** + * This method returns data about the columns returned as part of the + * result set as a <code>ResultSetMetaData</code> instance. + * + * @return The <code>ResultSetMetaData</code> instance for this result set. + * @exception SQLException If an error occurs. + */ + ResultSetMetaData getMetaData() throws SQLException; + + /** + * This method returns the value of the specified column as a Java + * <code>Object</code>. + * + * @param columnIndex The index of the column to return. + * @return The column value as an <code>Object</code>. + * @exception SQLException If an error occurs. + */ + Object getObject(int columnIndex) throws SQLException; + + /** + * This method returns the value of the specified column as a Java + * <code>Object</code>. + * + * @param columnName The name of the column to return. + * @return The column value as an <code>Object</code>. + * @exception SQLException If an error occurs. + */ + Object getObject(String columnName) throws SQLException; + + /** + * This method returns the column index of the specified named column. + * + * @param columnName The name of the column. + * @return The index of the column. + * @exception SQLException If an error occurs. + */ + int findColumn(String columnName) 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 columnIndex The index of the column to return. + * @return The column value as an character <code>Reader</code>. + * @exception SQLException If an error occurs. + */ + Reader getCharacterStream(int columnIndex) 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 columnName The name of the column to return. + * @return The column value as an character <code>Reader</code>. + * @exception SQLException If an error occurs. + */ + Reader getCharacterStream(String columnName) throws SQLException; + + /** + * This method returns the value of the specified column as a Java + * <code>BigDecimal</code>. + * + * @param columnIndex The index of the column to return. + * @return The column value as a <code>BigDecimal</code>. + * @exception SQLException If an error occurs. + */ + BigDecimal getBigDecimal(int columnIndex) throws SQLException; + + /** + * This method returns the value of the specified column as a Java + * <code>BigDecimal</code>. + * + * @param columnName The name of the column to return. + * @return The column value as a <code>BigDecimal</code>. + * @exception SQLException If an error occurs. + */ + BigDecimal getBigDecimal(String columnName) 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. + */ + 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. + */ + 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. + */ + 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. + */ + boolean isLast() throws SQLException; + + /** + * This method repositions the cursor to before the first row in the + * result set. + * + * @exception SQLException If an error occurs. + */ + void beforeFirst() throws SQLException; + + /** + * This method repositions the cursor to after the last row in the result + * set. + * + * @exception SQLException If an error occurs. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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 rows The number of row positions to move. + * @return <code>true</code> if the current position was changed, + * <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean relative(int rows) 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. + */ + boolean previous() 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. The + * allowed values are the <code>FETCH_*</code> constants + * defined in this interface. + * @exception SQLException If an error occurs. + */ + 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. + */ + 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. + */ + 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. + */ + int getFetchSize() throws SQLException; + + /** + * This method returns the result set type of this result set. This will + * be one of the <code>TYPE_*</code> constants defined in this interface. + * + * @return The result set type. + * @exception SQLException If an error occurs. + */ + int getType() throws SQLException; + + /** + * This method returns the concurrency type of this result set. This will + * be one of the <code>CONCUR_*</code> constants defined in this interface. + * + * @return The result set concurrency type. + * @exception SQLException If an error occurs. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + * + * @param columnIndex The index of the column to update. + * @exception SQLException If an error occurs. + */ + void updateNull(int columnIndex) 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 columnIndex The index of the column to update. + * @param value The new value of the column. + * @exception SQLException If an error occurs. + */ + void updateBoolean(int columnIndex, 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 columnIndex The index of the column to update. + * @param value The new value of the column. + * @exception SQLException If an error occurs. + */ + void updateByte(int columnIndex, 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 columnIndex The index of the column to update. + * @param value The new value of the column. + * @exception SQLException If an error occurs. + */ + void updateShort(int columnIndex, 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 columnIndex The index of the column to update. + * @param value The new value of the column. + * @exception SQLException If an error occurs. + */ + void updateInt(int columnIndex, 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 columnIndex The index of the column to update. + * @param value The new value of the column. + * @exception SQLException If an error occurs. + */ + void updateLong(int columnIndex, 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 columnIndex The index of the column to update. + * @param value The new value of the column. + * @exception SQLException If an error occurs. + */ + void updateFloat(int columnIndex, 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 columnIndex The index of the column to update. + * @param value The new value of the column. + * @exception SQLException If an error occurs. + */ + void updateDouble(int columnIndex, 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 columnIndex The index of the column to update. + * @param value The new value of the column. + * @exception SQLException If an error occurs. + */ + void updateBigDecimal(int columnIndex, 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 columnIndex The index of the column to update. + * @param value The new value of the column. + * @exception SQLException If an error occurs. + */ + void updateString(int columnIndex, 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 columnIndex The index of the column to update. + * @param value The new value of the column. + * @exception SQLException If an error occurs. + */ + void updateBytes(int columnIndex, 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 columnIndex The index of the column to update. + * @param value The new value of the column. + * @exception SQLException If an error occurs. + */ + void updateDate(int columnIndex, 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 columnIndex The index of the column to update. + * @param value The new value of the column. + * @exception SQLException If an error occurs. + */ + void updateTime(int columnIndex, 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 columnIndex The index of the column to update. + * @param value The new value of the column. + * @exception SQLException If an error occurs. + */ + void updateTimestamp(int columnIndex, 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 columnIndex The index of the column to update. + * @param stream The stream from which the column value is updated. + * @param count The length of the stream. + * @exception SQLException If an error occurs. + */ + void updateAsciiStream(int columnIndex, InputStream stream, int count) + 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 columnIndex The index of the column to update. + * @param stream The stream from which the column value is updated. + * @param count The length of the stream. + * @exception SQLException If an error occurs. + */ + void updateBinaryStream(int columnIndex, InputStream stream, int count) + 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 columnIndex The index of the column to update. + * @param reader The reader from which the column value is updated. + * @param count The length of the stream. + * @exception SQLException If an error occurs. + */ + void updateCharacterStream(int columnIndex, Reader reader, int count) + 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 columnIndex 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. + */ + void updateObject(int columnIndex, Object value, int scale) + 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 columnIndex The index of the column to update. + * @param value The new value of the column. + * @exception SQLException If an error occurs. + */ + void updateObject(int columnIndex, Object value) 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. + * + * @param columnName The name of the column to update. + * @exception SQLException If an error occurs. + */ + void updateNull(String columnName) 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 columnName The name of the column to update. + * @param value The new value of the column. + * @exception SQLException If an error occurs. + */ + void updateBoolean(String columnName, 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 columnName The name of the column to update. + * @param value The new value of the column. + * @exception SQLException If an error occurs. + */ + void updateByte(String columnName, 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 columnName The name of the column to update. + * @param value The new value of the column. + * @exception SQLException If an error occurs. + */ + void updateShort(String columnName, 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 columnName The name of the column to update. + * @param value The new value of the column. + * @exception SQLException If an error occurs. + */ + void updateInt(String columnName, 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 columnName The name of the column to update. + * @param value The new value of the column. + * @exception SQLException If an error occurs. + */ + void updateLong(String columnName, 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 columnName The name of the column to update. + * @param value The new value of the column. + * @exception SQLException If an error occurs. + */ + void updateFloat(String columnName, 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 columnName The name of the column to update. + * @param value The new value of the column. + * @exception SQLException If an error occurs. + */ + void updateDouble(String columnName, 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 columnName The name of the column to update. + * @param value The new value of the column. + * @exception SQLException If an error occurs. + */ + void updateBigDecimal(String columnName, 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 columnName The name of the column to update. + * @param value The new value of the column. + * @exception SQLException If an error occurs. + */ + void updateString(String columnName, 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 columnName The name of the column to update. + * @param value The new value of the column. + * @exception SQLException If an error occurs. + */ + void updateBytes(String columnName, 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 columnName The name of the column to update. + * @param value The new value of the column. + * @exception SQLException If an error occurs. + */ + void updateDate(String columnName, 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 columnName The name of the column to update. + * @param value The new value of the column. + * @exception SQLException If an error occurs. + */ + void updateTime(String columnName, 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 columnName The name of the column to update. + * @param value The new value of the column. + * @exception SQLException If an error occurs. + */ + void updateTimestamp(String columnName, 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 columnName The name of the column to update. + * @param stream The stream from which the column value is updated. + * @param count The length of the stream. + * @exception SQLException If an error occurs. + */ + void updateAsciiStream(String columnName, InputStream stream, int count) + 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 columnName The name of the column to update. + * @param stream The stream from which the column value is updated. + * @param count The length of the stream. + * @exception SQLException If an error occurs. + */ + void updateBinaryStream(String columnName, InputStream stream, int count) + 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 columnName The name of the column to update. + * @param reader The reader from which the column value is updated. + * @param count The length of the stream. + * @exception SQLException If an error occurs. + */ + void updateCharacterStream(String columnName, Reader reader, int count) + 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 columnName 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. + */ + void updateObject(String columnName, Object value, int scale) + 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 columnName The name of the column to update. + * @param value The new value of the column. + * @exception SQLException If an error occurs. + */ + void updateObject(String columnName, Object value) 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. + */ + void insertRow() throws SQLException; + + /** + * This method updates the current row in the database. + * + * @exception SQLException If an error occurs. + */ + void updateRow() throws SQLException; + + /** + * This method deletes the current row in the database. + * + * @exception SQLException If an error occurs. + */ + void deleteRow() throws SQLException; + + /** + * This method refreshes the contents of the current row from the database. + * + * @exception SQLException If an error occurs. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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 columnIndex 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. + */ + Object getObject(int columnIndex, Map<String, Class<?>> map) + throws SQLException; + + /** + * This method returns a <code>Ref</code> for the specified column which + * represents the structured type for the column. + * + * @param columnIndex The index of the column to return. + * @return A <code>Ref</code> object for the column + * @exception SQLException If an error occurs. + */ + Ref getRef(int columnIndex) throws SQLException; + + /** + * This method returns the specified column value as a BLOB. + * + * @param columnIndex The index of the column value to return. + * @return The value of the column as a BLOB. + * @exception SQLException If an error occurs. + */ + Blob getBlob(int columnIndex) throws SQLException; + + /** + * This method returns the specified column value as a CLOB. + * + * @param columnIndex The index of the column value to return. + * @return The value of the column as a CLOB. + * @exception SQLException If an error occurs. + */ + Clob getClob(int columnIndex) throws SQLException; + + /** + * This method returns the specified column value as an <code>Array</code>. + * + * @param columnIndex 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. + */ + Array getArray(int columnIndex) 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 columnName 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. + */ + Object getObject(String columnName, Map<String, Class<?>> map) + throws SQLException; + + /** + * This method returns a <code>Ref</code> for the specified column which + * represents the structured type for the column. + * + * @param columnName The name of the column to return. + * @return A <code>Ref</code> object for the column + * @exception SQLException If an error occurs. + */ + Ref getRef(String columnName) throws SQLException; + + /** + * This method returns the specified column value as a BLOB. + * + * @param columnName The name of the column value to return. + * @return The value of the column as a BLOB. + * @exception SQLException If an error occurs. + */ + Blob getBlob(String columnName) throws SQLException; + + /** + * This method returns the specified column value as a CLOB. + * + * @param columnName The name of the column value to return. + * @return The value of the column as a CLOB. + * @exception SQLException If an error occurs. + */ + Clob getClob(String columnName) throws SQLException; + + /** + * This method returns the specified column value as an <code>Array</code>. + * + * @param columnName 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. + */ + Array getArray(String columnName) 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 columnIndex 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. + */ + Date getDate(int columnIndex, 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 columnName 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. + */ + Date getDate(String columnName, 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 columnIndex 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. + */ + Time getTime(int columnIndex, 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 columnName 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. + */ + Time getTime(String columnName, 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 columnIndex 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. + */ + Timestamp getTimestamp(int columnIndex, 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 columnName 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. + */ + Timestamp getTimestamp(String columnName, Calendar cal) + throws SQLException; + + /** + * This method returns the specified column value as a + * <code>java.net.URL</code>. + * + * @param columnIndex The index of the column value to return. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + URL getURL(int columnIndex) throws SQLException; + + /** + * This method returns the specified column value as a + * <code>java.net.URL</code>. + * + * @param columnName The name of the column value to return. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + URL getURL(String columnName) throws SQLException; + + /** + * This method updates the specified column to have a + * <code>java.sql.Ref</code> value. + * This does not update the actual database. <code>updateRow</code> must be + * called in order to do that. + * + * @parm columnIndex The index of the column value to update. + * @parm value The <code>java.sql.Ref</code> used to set the new value + * of the column. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + void updateRef(int columnIndex, Ref value) throws SQLException; + + /** + * This method updates the specified column to have a + * <code>java.sql.Ref</code> value. + * This does not update the actual database. <code>updateRow</code> must be + * called in order to do that. + * + * @parm columnName The name of the column value to update. + * @parm value The <code>java.sql.Ref</code> used to set the new value + * of the column. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + void updateRef(String columnName, Ref value) throws SQLException; + + /** + * This method updates the specified column to have a + * <code>java.sql.Blob</code> value. + * This does not update the actual database. <code>updateRow</code> must be + * called in order to do that. + * + * @parm columnIndex The index of the column value to update. + * @parm value The <code>java.sql.Blob</code> used to set the new value + * of the column. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + void updateBlob(int columnIndex, Blob value) throws SQLException; + + /** + * This method updates the specified column to have a + * <code>java.sql.Blob</code> value. + * This does not update the actual database. <code>updateRow</code> must be + * called in order to do that. + * + * @parm columnName The name of the column value to update. + * @parm value The <code>java.sql.Blob</code> used to set the new value + * of the column. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + void updateBlob(String columnName, Blob value) throws SQLException; + + /** + * This method updates the specified column to have a + * <code>java.sql.Clob</code> value. + * This does not update the actual database. <code>updateRow</code> must be + * called in order to do that. + * + * @parm columnIndex The index of the column value to update. + * @parm value The <code>java.sql.Clob</code> used to set the new value + * of the column. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + void updateClob(int columnIndex, Clob value) throws SQLException; + + /** + * This method updates the specified column to have a + * <code>java.sql.Clob</code> value. + * This does not update the actual database. <code>updateRow</code> must be + * called in order to do that. + * + * @parm columnName The name of the column value to update. + * @parm value The <code>java.sql.Clob</code> used to set the new value + * of the column. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + void updateClob(String columnName, Clob value) throws SQLException; + + /** + * This method updates the specified column to have a + * <code>java.sqlArray</code> value. + * This does not update the actual database. <code>updateRow</code> must be + * called in order to do that. + * + * @parm columnIndex The index of the column value to update. + * @parm value The new value of the column. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + void updateArray(int columnIndex, Array value) throws SQLException; + + /** + * This method updates the specified column to have a + * <code>java.sqlArray</code> value. + * This does not update the actual database. <code>updateRow</code> must be + * called in order to do that. + * + * @parm columnName The name of the column value to update. + * @parm value The new value of the column. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + void updateArray(String columnName, Array value) throws SQLException; +} diff --git a/libjava/classpath/java/sql/ResultSetMetaData.java b/libjava/classpath/java/sql/ResultSetMetaData.java new file mode 100644 index 000000000..98485e3d3 --- /dev/null +++ b/libjava/classpath/java/sql/ResultSetMetaData.java @@ -0,0 +1,281 @@ +/* ResultSetMetaData.java -- Returns information about the ResultSet + Copyright (C) 1999, 2000, 2002, 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package java.sql; + +/** + * This interface provides a mechanism for obtaining information about + * the columns that are present in a <code>ResultSet</code>. + * + * <p> Note that in this class column indices start at 1, not 0.</p> + * + * @author Aaron M. Renn (arenn@urbanophile.com) + */ +public interface ResultSetMetaData +{ + /** + * The column does not allow NULL's. + */ + int columnNoNulls = 0; + + /** + * The column allows NULL's. + */ + int columnNullable = 1; + + /** + * It is unknown whether or not the column allows NULL's. + */ + int columnNullableUnknown = 2; + + /** + * This method returns the number of columns in the result set. + * + * @return The number of columns in the result set. + * @exception SQLException If an error occurs. + */ + int getColumnCount() throws SQLException; + + /** + * This method test whether or not the column is an auto-increment column. + * Auto-increment columns are read-only. + * + * @param columnIndex The index of the column to test. + * @return <code>true</code> if the column is auto-increment, <code>false</code> + * otherwise. + * @exception SQLException If an error occurs. + */ + boolean isAutoIncrement(int columnIndex) throws SQLException; + + /** + * This method tests whether or not a column is case sensitive in its values. + * + * @param columnIndex The index of the column to test. + * @return <code>true</code> if the column value is case sensitive, + * <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean isCaseSensitive(int columnIndex) throws SQLException; + + /** + * This method tests whether not the specified column can be used in + * a WHERE clause. + * + * @param columnIndex The index of the column to test. + * @return <code>true</code> if the column may be used in a WHERE clause, + * <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean isSearchable(int columnIndex) throws SQLException; + + /** + * This method tests whether or not the column stores a monetary value. + * + * @param columnIndex The index of the column to test. + * @return <code>true</code> if the column contains a monetary value, + * <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean isCurrency(int columnIndex) throws SQLException; + + /** + * This method returns a value indicating whether or not the specified + * column may contain a NULL value. + * + * @param columnIndex The index of the column to test. + * @return A constant indicating whether or not the column can contain NULL, + * which will be one of <code>columnNoNulls</code>, + * <code>columnNullable</code>, or <code>columnNullableUnknown</code>. + * @exception SQLException If an error occurs. + */ + int isNullable(int columnIndex) throws SQLException; + + /** + * This method tests whether or not the value of the specified column + * is signed or unsigned. + * + * @param columnIndex The index of the column to test. + * @return <code>true</code> if the column value is signed, <code>false</code> + * otherwise. + * @exception SQLException If an error occurs. + */ + boolean isSigned(int columnIndex) throws SQLException; + + /** + * This method returns the maximum number of characters that can be used + * to display a value in this column. + * + * @param columnIndex The index of the column to check. + * @return The maximum number of characters that can be used to display a + * value for this column. + * @exception SQLException If an error occurs. + */ + int getColumnDisplaySize(int columnIndex) throws SQLException; + + /** + * This method returns a string that should be used as a caption for this + * column for user display purposes. + * + * @param columnIndex The index of the column to check. + * @return A display string for the column. + * @exception SQLException If an error occurs. + */ + String getColumnLabel(int columnIndex) throws SQLException; + + /** + * This method returns the name of the specified column. + * + * @param columnIndex The index of the column to return the name of. + * @return The name of the column. + * @exception SQLException If an error occurs. + */ + String getColumnName(int columnIndex) throws SQLException; + + /** + * This method returns the name of the schema that contains the specified + * column. + * + * @param columnIndex The index of the column to check the schema name for. + * @return The name of the schema that contains the column. + * @exception SQLException If an error occurs. + */ + String getSchemaName(int columnIndex) throws SQLException; + + /** + * This method returns the precision of the specified column, which is the + * number of decimal digits it contains. + * + * @param columnIndex The index of the column to check the precision on. + * @return The precision of the specified column. + * @exception SQLException If an error occurs. + */ + int getPrecision(int columnIndex) throws SQLException; + + /** + * This method returns the scale of the specified column, which is the + * number of digits to the right of the decimal point. + * + * @param columnIndex The index column to check the scale of. + * @return The scale of the column. + * @exception SQLException If an error occurs. + */ + int getScale(int columnIndex) throws SQLException; + + /** + * This method returns the name of the table containing the specified + * column. + * + * @param columnIndex The index of the column to check the table name for. + * @return The name of the table containing the column. + * @exception SQLException If an error occurs. + */ + String getTableName(int columnIndex) throws SQLException; + + /** + * This method returns the name of the catalog containing the specified + * column. + * + * @param columnIndex The index of the column to check the catalog name for. + * @return The name of the catalog containing the column. + * @exception SQLException If an error occurs. + */ + String getCatalogName(int columnIndex) throws SQLException; + + /** + * This method returns the SQL type of the specified column. This will + * be one of the constants from <code>Types</code>. + * + * @param columnIndex The index of the column to check the SQL type of. + * @return The SQL type for this column. + * @exception SQLException If an error occurs. + * @see Types + */ + int getColumnType(int columnIndex) throws SQLException; + + /** + * This method returns the name of the SQL type for this column. + * + * @param columnIndex The index of the column to check the SQL type name for. + * @return The name of the SQL type for this column. + * @exception SQLException If an error occurs. + */ + String getColumnTypeName(int columnIndex) throws SQLException; + + /** + * This method tests whether or not the specified column is read only. + * + * @param columnIndex The index of the column to check. + * @return <code>true</code> if the column is read only, <code>false</code> + * otherwise. + * @exception SQLException If an error occurs. + */ + boolean isReadOnly(int columnIndex) throws SQLException; + + /** + * This method tests whether or not the column may be writable. This + * does not guarantee that a write will be successful. + * + * @param columnIndex The index of the column to check for writability. + * @return <code>true</code> if the column may be writable, + * <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean isWritable(int columnIndex) throws SQLException; + + /** + * This method tests whether or not the column is writable. This + * does guarantee that a write will be successful. + * + * @param columnIndex The index of the column to check for writability. + * @return <code>true</code> if the column is writable, + * <code>false</code> otherwise. + * @exception SQLException If an error occurs. + */ + boolean isDefinitelyWritable(int columnIndex) 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 columnIndex 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. + */ + String getColumnClassName(int columnIndex) throws SQLException; +} diff --git a/libjava/classpath/java/sql/SQLData.java b/libjava/classpath/java/sql/SQLData.java new file mode 100644 index 000000000..97a42a443 --- /dev/null +++ b/libjava/classpath/java/sql/SQLData.java @@ -0,0 +1,72 @@ +/* SQLData.java -- Custom mapping for a user defined datatype + Copyright (C) 1999, 2000, 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +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. + */ + 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 typeName The data type name of the data on the stream. + * @exception SQLException If an error occurs. + */ + void readSQL(SQLInput stream, String typeName) 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. + */ + void writeSQL(SQLOutput stream) throws SQLException; +} diff --git a/libjava/classpath/java/sql/SQLException.java b/libjava/classpath/java/sql/SQLException.java new file mode 100644 index 000000000..d8d845c6b --- /dev/null +++ b/libjava/classpath/java/sql/SQLException.java @@ -0,0 +1,167 @@ +/* SQLException.java -- General SQL exception + 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., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package java.sql; + +/** + * This exception is thrown when a database error occurs. + * + * @author Aaron M. Renn (arenn@urbanophile.com) + */ +public class SQLException extends Exception +{ + static final long serialVersionUID = 2135244094396331484L; + + /** + * This is the next exception in the chain + */ + private SQLException next; + + /** + * This is the state of the SQL statement at the time of the error. + */ + private String SQLState; + + /** + * The vendor error code for this error + */ + private int vendorCode; + + /** + * This method initializes a nwe instance of <code>SQLException</code> + * with the specified descriptive error message, SQL state string, and + * vendor code. + * + * @param message A string describing the nature of the error. + * @param SQLState A string containing the SQL state of the error. + * @param vendorCode The vendor error code associated with this error. + */ + public SQLException(String message, String SQLState, int vendorCode) + { + super(message); + this.SQLState = SQLState; + this.vendorCode = vendorCode; + } + + /** + * This method initializes a new instance of <code>SQLException</code> + * with the specified descriptive error message and SQL state string. + * The vendor error code of this instance will be 0. + * + * @param message A string describing the nature of the error. + * @param SQLState A string containing the SQL state of the error. + */ + public SQLException(String message, String SQLState) + { + this(message, SQLState, 0); + } + + /** + * This method initializes a new instance of <code>SQLException</code> + * with the specified descriptive error message. The SQL state of this + * instance will be <code>null</code> and the vendor error code will be 0. + * + * @param message A string describing the nature of the error. + */ + public SQLException(String message) + { + this(message, null, 0); + } + + /** + * This method initializes a new instance of <code>SQLException</code> + * that does not have a descriptive messages and SQL state, and which + * has a vendor error code of 0. + */ + public SQLException() + { + this(null, null, 0); + } + + /** + * This method returns the SQLState information associated with this + * error. The value returned is a <code>String</code> which is formatted + * using the XOPEN SQL state conventions. + * + * @return The SQL state, which may be <code>null</code>. + */ + public String getSQLState() + { + return SQLState; + } + + /** + * This method returns the vendor specific error code associated with + * this error. + * + * @return The vendor specific error code associated with this error. + */ + public int getErrorCode() + { + return vendorCode; + } + + /** + * This method returns the exception that is chained to this object. + * + * @return The exception chained to this object, which may be + * <code>null</code>. + */ + public SQLException getNextException() + { + return next; + } + + /** + * This method adds a new exception to the end of the chain of exceptions + * that are chained to this object. + * + * @param e The exception to add to the end of the chain. + */ + public void setNextException(SQLException e) + { + if (e == null) + return; + + SQLException list_entry = this; + while (list_entry.getNextException() != null) + list_entry = list_entry.getNextException(); + + list_entry.next = e; + } +} diff --git a/libjava/classpath/java/sql/SQLInput.java b/libjava/classpath/java/sql/SQLInput.java new file mode 100644 index 000000000..e277a5020 --- /dev/null +++ b/libjava/classpath/java/sql/SQLInput.java @@ -0,0 +1,258 @@ +/* SQLInput.java -- Read SQL values from a stream + Copyright (C) 1999, 2000, 2002 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., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package java.sql; + +import java.io.InputStream; +import java.io.Reader; +import java.math.BigDecimal; +import java.net.URL; + +/** + * 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + Timestamp readTimestamp() 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. + */ + Reader readCharacterStream() 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. + */ + 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. + */ + InputStream readBinaryStream() 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + boolean wasNull() throws SQLException; + + /** + * @since 1.4 + */ + URL readURL() throws SQLException; +} diff --git a/libjava/classpath/java/sql/SQLOutput.java b/libjava/classpath/java/sql/SQLOutput.java new file mode 100644 index 000000000..cd075f1d2 --- /dev/null +++ b/libjava/classpath/java/sql/SQLOutput.java @@ -0,0 +1,267 @@ +/* SQLOutput.java -- Write SQL values to a stream + Copyright (C) 1999, 2000, 2002, 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package java.sql; + +import java.io.InputStream; +import java.io.Reader; +import java.math.BigDecimal; +import java.net.URL; + +/** + * 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + void writeDate(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. + */ + void writeTime(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. + */ + void writeTimestamp(Timestamp value) throws SQLException; + + /** + * This method writes the specified Java character stream + * to the SQL stream. + * + * @param stream The stream that holds the character data to write. + * @exception SQLException If an error occurs. + */ + void writeCharacterStream(Reader stream) throws SQLException; + + /** + * This method writes the specified ASCII text stream + * to the SQL stream. + * + * @param stream The stream that holds the ASCII data to write. + * @exception SQLException If an error occurs. + */ + void writeAsciiStream(InputStream stream) throws SQLException; + + /** + * This method writes the specified uninterpreted binary byte stream + * to the SQL stream. + * + * @param stream The stream that holds the binary data to write. + * @exception SQLException If an error occurs. + */ + void writeBinaryStream(InputStream stream) 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. + */ + void writeObject(SQLData value) throws SQLException; + + /** + * This method writes the specified Java SQL <code>Ref</code> object + * to the SQL stream. + * + * @param value The <code>Ref</code> object to write to the stream. + * @exception SQLException If an error occurs. + * @see Ref + */ + void writeRef(Ref value) throws SQLException; + + + /** + * This method writes the specified Java SQL <code>Blob</code> object + * to the SQL stream. + * + * @param value The <code>Blob</code> object to write to the stream. + * @exception SQLException If an error occurs. + * @see Blob + */ + void writeBlob(Blob value) throws SQLException; + + /** + * This method writes the specified Java SQL <code>Clob</code> object + * to the SQL stream. + * + * @param value The <code>Clob</code> object to write to the stream. + * @exception SQLException If an error occurs. + * @see Clob + */ + void writeClob(Clob value) throws SQLException; + + /** + * This method writes the specified Java SQL <code>Struct</code> object + * to the SQL stream. + * + * @param value The <code>Struct</code> object to write to the stream. + * @exception SQLException If an error occurs. + * @see Struct + */ + 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. + */ + void writeArray(Array value) throws SQLException; + + /** + * This method writes the specified <code>java.net.URL</code> object to the + * SQL stream. + * + * @param value The value to write to the stream. + * @exception SQLException If an error occurs. + * @since 1.4 + */ + void writeURL(URL value) throws SQLException; +} diff --git a/libjava/classpath/java/sql/SQLPermission.java b/libjava/classpath/java/sql/SQLPermission.java new file mode 100644 index 000000000..ed3dd7f9e --- /dev/null +++ b/libjava/classpath/java/sql/SQLPermission.java @@ -0,0 +1,57 @@ +/* SQLPermission.java + Copyright (C) 2002 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., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package java.sql; + +import java.security.BasicPermission; + +/** + * @since 1.3 + */ +public final class SQLPermission extends BasicPermission +{ + public SQLPermission(String name) + { + super(name); + } + + public SQLPermission(String name, String actions) + { + super(name, actions); + } +} diff --git a/libjava/classpath/java/sql/SQLWarning.java b/libjava/classpath/java/sql/SQLWarning.java new file mode 100644 index 000000000..c2cee0ad5 --- /dev/null +++ b/libjava/classpath/java/sql/SQLWarning.java @@ -0,0 +1,120 @@ +/* SQLWarning.java -- Database access warnings. + Copyright (C) 1999, 2000, 2002, 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package java.sql; + +/** + * This exception is thrown when a database warning occurs. + * + * @author Aaron M. Renn (arenn@urbanophile.com) + */ +public class SQLWarning extends SQLException +{ + static final long serialVersionUID = 3917336774604784856L; + + /** + * This method initializes a nwe instance of <code>SQLWarning</code> + * with the specified descriptive error message, SQL state string, and + * vendor code. + * + * @param message A string describing the nature of the error. + * @param SQLState A string containing the SQL state of the error. + * @param vendorCode The vendor error code associated with this error. + */ + public SQLWarning(String message, String SQLState, int vendorCode) + { + super(message, SQLState, vendorCode); + } + + /** + * This method initializes a new instance of <code>SQLWarning</code> + * with the specified descriptive error message and SQL state string. + * The vendor error code of this instance will be 0. + * + * @param message A string describing the nature of the error. + * @param SQLState A string containing the SQL state of the error. + */ + public SQLWarning(String message, String SQLState) + { + super(message, SQLState); + } + + /** + * This method initializes a new instance of <code>SQLWarning</code> + * with the specified descriptive error message. The SQL state of this + * instance will be <code>null</code> and the vendor error code will be 0. + * + * @param message A string describing the nature of the error. + */ + public SQLWarning(String message) + { + super(message); + } + + /** + * This method initializes a new instance of <code>SQLWarning</code> + * that does not have a descriptive messages and SQL state, and which + * has a vendor error code of 0. + */ + public SQLWarning() + { + super(); + } + + /** + * This method returns the exception that is chained to this object. + * + * @return The exception chained to this object, which may be + * <code>null</code>. + */ + public SQLWarning getNextWarning() + { + return (SQLWarning) super.getNextException(); + } + + /** + * This method adds a new exception to the end of the chain of exceptions + * that are chained to this object. + * + * @param w The exception to add to the end of the chain. + */ + public void setNextWarning(SQLWarning w) + { + super.setNextException(w); + } +} diff --git a/libjava/classpath/java/sql/Savepoint.java b/libjava/classpath/java/sql/Savepoint.java new file mode 100644 index 000000000..6526dfb44 --- /dev/null +++ b/libjava/classpath/java/sql/Savepoint.java @@ -0,0 +1,55 @@ +/* SavePoint.java -- Returns information about the ResultSet + Copyright (C) 2002 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., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package java.sql; + +/** + * @since 1.4 + */ +public interface Savepoint +{ + /** + * @since 1.4 + */ + int getSavepointId() throws SQLException; + + /** + * @since 1.4 + */ + String getSavepointName() throws SQLException; +} diff --git a/libjava/classpath/java/sql/Statement.java b/libjava/classpath/java/sql/Statement.java new file mode 100644 index 000000000..1b57fb3ce --- /dev/null +++ b/libjava/classpath/java/sql/Statement.java @@ -0,0 +1,375 @@ +/* Statement.java -- Interface for executing SQL statements. + Copyright (C) 1999, 2000, 2002, 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package java.sql; + +/** + * This interface provides a mechanism for executing SQL statements. + * + * @author Aaron M. Renn (arenn@urbanophile.com) + */ +public interface Statement +{ + int CLOSE_CURRENT_RESULT = 1; + int KEEP_CURRENT_RESULT = 2; + int CLOSE_ALL_RESULTS = 3; + int SUCCESS_NO_INFO = -2; + int EXECUTE_FAILED = -3; + int RETURN_GENERATED_KEYS = 1; + int NO_GENERATED_KEYS = 2; + + /** + * This method executes the specified SQL SELECT statement and returns a + * (possibly empty) <code>ResultSet</code> with the results of the query. + * + * @param sql The SQL statement to execute. + * @return The result set of the SQL statement. + * @exception SQLException If an error occurs. + */ + ResultSet executeQuery(String sql) throws SQLException; + + /** + * This method executes the specified SQL INSERT, UPDATE, or DELETE statement + * and returns the number of rows affected, which may be 0. + * + * @param sql The SQL statement to execute. + * @return The number of rows affected by the SQL statement. + * @exception SQLException If an error occurs. + */ + int executeUpdate(String sql) throws SQLException; + + /** + * This method closes the statement and frees any associated resources. + * + * @exception SQLException If an error occurs. + */ + void close() throws SQLException; + + /** + * This method returns the maximum length of any column value in bytes. + * + * @return The maximum length of any column value in bytes. + * @exception SQLException If an error occurs. + */ + int getMaxFieldSize() throws SQLException; + + /** + * This method sets the limit for the maximum length of any column in bytes. + * + * @param maxSize The new maximum length of any column in bytes. + * @exception SQLException If an error occurs. + */ + void setMaxFieldSize(int maxSize) throws SQLException; + + /** + * This method returns the maximum possible number of rows in a result set. + * + * @return The maximum possible number of rows in a result set. + * @exception SQLException If an error occurs. + */ + int getMaxRows() throws SQLException; + + /** + * This method sets the maximum number of rows that can be present in a + * result set. + * + * @param maxRows The maximum possible number of rows in a result set. + * @exception SQLException If an error occurs. + */ + void setMaxRows(int maxRows) throws SQLException; + + /** + * This method sets the local escape processing mode on or off. The + * default value is on. + * + * @param escape <code>true</code> to enable local escape processing, + * <code>false</code> to disable it. + * @exception SQLException If an error occurs. + */ + void setEscapeProcessing(boolean escape) throws SQLException; + + /** + * The method returns the number of seconds a statement may be in process + * before timing out. A value of 0 means there is no timeout. + * + * @return The SQL statement timeout in seconds. + * @exception SQLException If an error occurs. + */ + int getQueryTimeout() throws SQLException; + + /** + * This method sets the number of seconds a statement may be in process + * before timing out. A value of 0 means there is no timeout. + * + * @param seconds The new SQL statement timeout value. + * @exception SQLException If an error occurs. + */ + void setQueryTimeout(int seconds) throws SQLException; + + /** + * This method cancels an outstanding statement, if the database supports + * that operation. + * + * @exception SQLException If an error occurs. + */ + void cancel() throws SQLException; + + /** + * This method returns the first SQL warning attached to this statement. + * Subsequent warnings will be chained to this one. + * + * @return The first SQL warning for this statement. + * @exception SQLException If an error occurs. + */ + SQLWarning getWarnings() throws SQLException; + + /** + * This method clears any SQL warnings that have been attached to this + * statement. + * + * @exception SQLException If an error occurs. + */ + void clearWarnings() throws SQLException; + + /** + * This method sets the cursor name that will be used by the result set. + * + * @param name The cursor name to use for this statement. + * @exception SQLException If an error occurs. + */ + void setCursorName(String name) throws SQLException; + + /** + * This method executes an arbitrary SQL statement of any time. The + * methods <code>getResultSet</code>, <code>getMoreResults</code> and + * <code>getUpdateCount</code> retrieve the results. + * + * @return <code>true</code> if a result set was returned, <code>false</code> + * if an update count was returned. + * @exception SQLException If an error occurs. + */ + boolean execute(String sql) throws SQLException; + + /** + * This method returns the result set of the SQL statement that was + * executed. This should be called only once per result set returned. + * + * @return The result set of the query, or <code>null</code> if there was + * no result set (for example, if the statement was an UPDATE). + * @exception SQLException If an error occurs. + * @see #execute(String) + * @see #execute(String, int) + * @see #execute(String, int[]) + * @see #execute(String, String[]) + */ + ResultSet getResultSet() throws SQLException; + + /** + * This method returns the update count of the SQL statement that was + * executed. This should be called only once per executed SQL statement. + * + * @return The update count of the query, or -1 if there was no update + * count (for example, if the statement was a SELECT). + * @exception SQLException If an error occurs. + * @see #execute(String) + * @see #execute(String, int) + * @see #execute(String, int[]) + * @see #execute(String, String[]) + */ + int getUpdateCount() throws SQLException; + + /** + * This method advances the result set pointer to the next result set, + * which can then be retrieved using <code>getResultSet</code> + * + * @return <code>true</code> if there is another result set, + * <code>false</code> otherwise (for example, the next result is an + * update count). + * @exception SQLException If an error occurs. + * @see #execute(String) + * @see #execute(String, int) + * @see #execute(String, int[]) + * @see #execute(String, String[]) + */ + boolean getMoreResults() 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. + */ + void setFetchDirection(int direction) 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. + */ + int getFetchDirection() 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. + */ + void setFetchSize(int numRows) 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. + */ + int getFetchSize() 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 + */ + 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 + */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + Connection getConnection() throws SQLException; + + /** + * @since 1.4 + */ + boolean getMoreResults(int current) throws SQLException; + + /** + * @since 1.4 + */ + ResultSet getGeneratedKeys() throws SQLException; + + /** + * @since 1.4 + */ + int executeUpdate(String sql, int autoGeneratedKeys) + throws SQLException; + + /** + * @since 1.4 + */ + int executeUpdate(String sql, int[] columnIndexes) + throws SQLException; + + /** + * @since 1.4 + */ + int executeUpdate(String sql, String[] columnNames) + throws SQLException; + + /** + * @since 1.4 + */ + boolean execute(String sql, int autoGeneratedKeys) + throws SQLException; + + /** + * @since 1.4 + */ + boolean execute(String sql, int[] columnIndexes) throws SQLException; + + /** + * @since 1.4 + */ + boolean execute(String sql, String[] columnNames) + throws SQLException; + + /** + * @since 1.4 + */ + int getResultSetHoldability() throws SQLException; +} diff --git a/libjava/classpath/java/sql/Struct.java b/libjava/classpath/java/sql/Struct.java new file mode 100644 index 000000000..897344b98 --- /dev/null +++ b/libjava/classpath/java/sql/Struct.java @@ -0,0 +1,77 @@ +/* Struct.java -- Mapping for a SQL structured type. + Copyright (C) 1999, 2000, 2002 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., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +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. + */ + 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. + */ + 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. + */ + Object[] getAttributes(Map<String, Class<?>> map) throws SQLException; +} diff --git a/libjava/classpath/java/sql/Time.java b/libjava/classpath/java/sql/Time.java new file mode 100644 index 000000000..8de163683 --- /dev/null +++ b/libjava/classpath/java/sql/Time.java @@ -0,0 +1,201 @@ +/* Time.java -- Wrapper around java.util.Date + Copyright (C) 1999, 2000, 2002, 2003, 2005, 2006 + 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., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package java.sql; + +import java.text.ParseException; +import java.text.SimpleDateFormat; + +/** + * This class is a wrapper around java.util.Date to allow the JDBC + * driver to identify the value as a SQL Time. + * + * @author Aaron M. Renn (arenn@urbanophile.com) + */ +public class Time extends java.util.Date +{ + static final long serialVersionUID = 8397324403548013681L; + + /** + * Used for parsing and formatting this date. + */ + private static SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss"); + + /** + * This method always throws an IllegalArgumentException. + * + * @throws IllegalArgumentException when it's called. + * @deprecated + */ + public int getDate() throws IllegalArgumentException + { + throw new IllegalArgumentException(); + } + + /** + * This method always throws an IllegalArgumentException. + * + * @throws IllegalArgumentException when it's called. + * @deprecated + */ + public int getDay() throws IllegalArgumentException + { + throw new IllegalArgumentException(); + } + + /** + * This method always throws an IllegalArgumentException. + * + * @throws IllegalArgumentException when it's called. + * @deprecated + */ + public int getMonth() throws IllegalArgumentException + { + throw new IllegalArgumentException(); + } + + /** + * This method always throws an IllegalArgumentException. + * + * @throws IllegalArgumentException when it's called. + * @deprecated + */ + public int getYear() throws IllegalArgumentException + { + throw new IllegalArgumentException(); + } + + /** + * This method always throws an IllegalArgumentException. + * + * @throws IllegalArgumentException when it's called. + * @deprecated + */ + public void setDate(int newValue) throws IllegalArgumentException + { + throw new IllegalArgumentException(); + } + + /** + * This method always throws an IllegalArgumentException. + * + * @throws IllegalArgumentException when it's called. + * @deprecated + */ + public void setMonth(int newValue) throws IllegalArgumentException + { + throw new IllegalArgumentException(); + } + + /** + * This method always throws an IllegalArgumentException. + * + * @throws IllegalArgumentException when it's called. + * @deprecated + */ + public void setYear(int newValue) throws IllegalArgumentException + { + throw new IllegalArgumentException(); + } + + /** + * This method returns a new instance of this class by parsing a + * date in JDBC format into a Java date. + * + * @param str The string to parse. + * @return The resulting <code>java.sql.Time</code> value. + */ + public static Time valueOf (String str) + { + try + { + java.util.Date d = (java.util.Date) sdf.parseObject(str); + + if (d == null) + throw new IllegalArgumentException(str); + else + return new Time(d.getTime()); + } + catch (ParseException e) + { + throw new IllegalArgumentException(str); + } + } + + /** + * This method initializes a new instance of this class with the + * specified year, month, and day. + * + * @param hour The hour for this Time (0-23) + * @param minute The minute for this time (0-59) + * @param second The second for this time (0-59) + * @deprecated + */ + public Time(int hour, int minute, int second) + { + super(System.currentTimeMillis()); + + setHours(hour); + setMinutes(minute); + setSeconds(second); + } + + /** + * This method initializes a new instance of this class with the + * specified time value representing the number of milliseconds since + * Jan 1, 1970 at 12:00 midnight GMT. + * + * @param date The time value to intialize this <code>Time</code> to. + */ + public Time(long date) + { + super(date); + } + + /** + * This method returns this date in JDBC format. + * + * @return This date as a string. + */ + public String toString () + { + return sdf.format (this); + } + +} diff --git a/libjava/classpath/java/sql/Timestamp.java b/libjava/classpath/java/sql/Timestamp.java new file mode 100644 index 000000000..9488f8e2d --- /dev/null +++ b/libjava/classpath/java/sql/Timestamp.java @@ -0,0 +1,319 @@ +/* Time.java -- Wrapper around java.util.Date + Copyright (C) 1999, 2000, 2003, 2004, 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package java.sql; + +import java.text.DecimalFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; + +/** + * This class is a wrapper around java.util.Date to allow the JDBC + * driver to identify the value as a SQL Timestamp. Note that this + * class also adds an additional field for nano-seconds, and so + * is not completely identical to <code>java.util.Date</code> as + * the <code>java.sql.Date</code> and <code>java.sql.Time</code> + * classes are. + * + * @author Aaron M. Renn (arenn@urbanophile.com) + */ +public class Timestamp extends java.util.Date +{ + static final long serialVersionUID = 2745179027874758501L; + + /** + * Used for parsing and formatting this date. + */ + private static SimpleDateFormat dateFormat = + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + private static DecimalFormat decimalFormat = new DecimalFormat("000000000"); + private static StringBuffer sbuf = new StringBuffer(29); + + /** + * The nanosecond value for this object + */ + private int nanos; + + /** + * This method returns a new instance of this class by parsing a + * date in JDBC format into a Java date. + * + * @param str The string to parse. + * @return The resulting <code>java.sql.Timestamp</code> value. + */ + public static Timestamp valueOf(String str) + { + int nanos = 0; + int dot = str.indexOf('.'); + if (dot != -1) + { + if (str.lastIndexOf('.') != dot) + throw new IllegalArgumentException(str); + + int len = str.length() - dot - 1; + if (len < 1 || len > 9) + throw new IllegalArgumentException(str); + + nanos = Integer.parseInt(str.substring(dot + 1)); + for (int i = len; i < 9; i++) + nanos *= 10; + + str = str.substring(0, dot); + + } + + try + { + java.util.Date d; + synchronized (dateFormat) + { + d = (java.util.Date) dateFormat.parseObject(str); + } + + if (d == null) + throw new IllegalArgumentException(str); + + Timestamp ts = new Timestamp(d.getTime() + nanos / 1000000); + ts.nanos = nanos; + return ts; + } + catch (ParseException e) + { + throw new IllegalArgumentException(str); + } + } + + /** + * This method initializes a new instance of this class with the + * specified year, month, and day. + * + * @param year The year for this Timestamp (year - 1900) + * @param month The month for this Timestamp (0-11) + * @param day The day for this Timestamp (1-31) + * @param hour The hour for this Timestamp (0-23) + * @param minute The minute for this Timestamp (0-59) + * @param second The second for this Timestamp (0-59) + * @param nanos The nanosecond value for this Timestamp (0 to 999,999,9999) + * @deprecated + */ + public Timestamp(int year, int month, int day, int hour, int minute, + int second, int nanos) + { + super(year, month, day, hour, minute, second); + this.nanos = nanos; + } + + /** + * This method initializes a new instance of this class with the + * specified time value representing the number of milliseconds since + * Jan 1, 1970 at 12:00 midnight GMT. + * + * @param date The time value to intialize this <code>Time</code> to. + */ + public Timestamp(long date) + { + super(date - (date % 1000)); + nanos = (int) (date % 1000) * 1000000; + } + + /** + * Return the value of this Timestamp as the number of milliseconds + * since Jan 1, 1970 at 12:00 midnight GMT. + */ + public long getTime() + { + return super.getTime() + (nanos / 1000000); + } + + /** + * This method returns this date in JDBC format. + * + * @return This date as a string. + */ + public String toString() + { + synchronized (dateFormat) + { + sbuf.setLength(0); + dateFormat.format(this, sbuf, null); + sbuf.append('.'); + decimalFormat.format(nanos, sbuf, null); + int end = sbuf.length() - 1; + while (end > 20 && sbuf.charAt(end) == '0') + end--; + return sbuf.substring(0, end + 1); + } + } + + /** + * This method returns the nanosecond value for this object. + * @return The nanosecond value for this object. + */ + public int getNanos() + { + return nanos; + } + + /** + * This method sets the nanosecond value for this object. + * + * @param nanos The nanosecond value for this object. + */ + public void setNanos(int nanos) + { + this.nanos = nanos; + } + + /** + * This methods tests whether this object is earlier than the specified + * object. + * + * @param ts The other <code>Timestamp</code> to test against. + * @return <code>true</code> if this object is earlier than the other object, + * <code>false</code> otherwise. + */ + public boolean before(Timestamp ts) + { + long time1 = getTime(); + long time2 = ts.getTime(); + if (time1 < time2 || (time1 == time2 && getNanos() < ts.getNanos())) + return true; + return false; + } + + /** + * This methods tests whether this object is later than the specified + * object. + * + * @param ts The other <code>Timestamp</code> to test against. + * + * @return <code>true</code> if this object is later than the other object, + * <code>false</code> otherwise. + */ + public boolean after(Timestamp ts) + { + long time1 = getTime(); + long time2 = ts.getTime(); + if (time1 > time2 || (time1 == time2 && getNanos() > ts.getNanos())) + return true; + return false; + } + + /** + * This method these the specified <code>Object</code> for equality + * against this object. This will be true if an only if the specified + * object is an instance of <code>Timestamp</code> and has the same + * time value fields. + * + * @param obj The object to test against for equality. + * + * @return <code>true</code> if the specified object is equal to this + * object, <code>false</code> otherwise. + */ + public boolean equals(Object obj) + { + if (!(obj instanceof Timestamp)) + return false; + + return equals((Timestamp) obj); + } + + /** + * This method tests the specified timestamp for equality against this + * object. This will be true if and only if the specified object is + * not <code>null</code> and contains all the same time value fields + * as this object. + * + * @param ts The <code>Timestamp</code> to test against for equality. + * + * @return <code>true</code> if the specified object is equal to this + * object, <code>false</code> otherwise. + */ + public boolean equals(Timestamp ts) + { + if (ts == null) + return false; + + if (ts.getTime() != getTime()) + return false; + + if (ts.getNanos() != getNanos()) + return false; + + return true; + } + + /** + * Compares this <code>Timestamp</code> to another one. + * + * @param ts The other Timestamp. + * @return <code>0</code>, if both <code>Timestamp</code>'s represent exactly + * the same date, a negative value if this <code>Timestamp</code> is + * before the specified <code>Timestamp</code> and a positive value + * otherwise. + * @since 1.2 + */ + public int compareTo(Timestamp ts) + { + int s = super.compareTo((java.util.Date) ts); + if (s != 0) + return s; + // If Date components were equal, then we check the nanoseconds. + return nanos - ts.nanos; + } + + /** + * Compares this <code>Timestamp</code> to another one. This behaves like + * <code>compareTo(Timestamp)</code>, but it may throw a + * <code>ClassCastException</code>, if the specified object is not of type + * <code>Timestamp</code>. + * + * @param obj The object to compare with. + * @return <code>0</code>, if both <code>Timestamp</code>'s represent exactly + * the same date, a negative value if this <code>Timestamp</code> is + * before the specified <code>Timestamp</code> and a positive value + * otherwise. + * @exception ClassCastException if obj is not of type Timestamp. + * @see #compareTo(Timestamp) + * @since 1.2 + */ + public int compareTo(java.util.Date obj) + { + return compareTo((Timestamp) obj); + } +} diff --git a/libjava/classpath/java/sql/Types.java b/libjava/classpath/java/sql/Types.java new file mode 100644 index 000000000..c07ef1353 --- /dev/null +++ b/libjava/classpath/java/sql/Types.java @@ -0,0 +1,85 @@ +/* Types.java -- SQL type constants + Copyright (C) 1999, 2001 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., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package java.sql; + +/** + * This class contains constants that are used to identify SQL data types. + * + * @author Aaron M. Renn (arenn@urbanophile.com) + */ +public class Types +{ + // These should be self explanatory. People need a SQL book, not + // Javadoc comments for these. + public static final int BIT = -7; + public static final int TINYINT = -6; + public static final int SMALLINT = 5; + public static final int INTEGER = 4; + public static final int BIGINT = -5; + public static final int FLOAT = 6; + public static final int REAL = 7; + public static final int DOUBLE = 8; + public static final int NUMERIC = 2; + public static final int DECIMAL = 3; + public static final int CHAR = 1; + public static final int VARCHAR = 12; + public static final int LONGVARCHAR = -1; + public static final int DATE = 91; + public static final int TIME = 92; + public static final int TIMESTAMP = 93; + public static final int BINARY = -2; + 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; + public static final int DATALINK = 70; + public static final int BOOLEAN = 16; + + // This class can't be instantiated. + private Types() + { + } +} diff --git a/libjava/classpath/java/sql/package.html b/libjava/classpath/java/sql/package.html new file mode 100644 index 000000000..e8982f529 --- /dev/null +++ b/libjava/classpath/java/sql/package.html @@ -0,0 +1,47 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<!-- package.html - describes classes in java.sql package. + Copyright (C) 2002 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., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. --> + +<html> +<head><title>GNU Classpath - java.sql</title></head> + +<body> +<p>Interfaces and classes to connect to a database and wrappers for data +in the database and result queries.</p> + +</body> +</html> |