Added: db/derby/code/trunk/java/stubs/jdbc3/java/sql/SQLException.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/stubs/jdbc3/java/sql/SQLException.java?rev=724735&view=auto ============================================================================== --- db/derby/code/trunk/java/stubs/jdbc3/java/sql/SQLException.java (added) +++ db/derby/code/trunk/java/stubs/jdbc3/java/sql/SQLException.java Tue Dec 9 07:06:09 2008 @@ -0,0 +1,153 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package java.sql; + +import java.io.Serializable; + +/** + * An Exception class that is used in conjunction with JDBC operations. It + * provides information about problems encountered with Database access and + * other problems related to JDBC + *

+ * The SQLException class provides the following information: + *

+ */ +public class SQLException extends Exception implements Serializable { + + private static final long serialVersionUID = 2135244094396331484L; + + private String SQLState = null; + + private int vendorCode = 0; + + private SQLException next = null; + + /** + * Creates an SQLException object. The Reason string is set to null, the + * SQLState string is set to null and the Error Code is set to 0. + */ + public SQLException() { + super(); + } + + /** + * Creates an SQLException object. The Reason string is set to the given + * reason string, the SQLState string is set to null and the Error Code is + * set to 0. + * + * @param theReason + * the string to use as the Reason string + */ + public SQLException(String theReason) { + this(theReason, null, 0); + } + + /** + * Creates an SQLException object. The Reason string is set to the given + * reason string, the SQLState string is set to the given SQLState string + * and the Error Code is set to 0. + * + * @param theReason + * the string to use as the Reason string + * @param theSQLState + * the string to use as the SQLState string + */ + public SQLException(String theReason, String theSQLState) { + this(theReason, theSQLState, 0); + } + + /** + * Creates an SQLException object. The Reason string is set to the given + * reason string, the SQLState string is set to the given SQLState string + * and the Error Code is set to the given error code value. + * + * @param theReason + * the string to use as the Reason string + * @param theSQLState + * the string to use as the SQLState string + * @param theErrorCode + * the integer value for the error code + */ + public SQLException(String theReason, String theSQLState, int theErrorCode) { + super(theReason); + SQLState = theSQLState; + vendorCode = theErrorCode; + } + + /** + * Returns the integer error code for this SQLException + * + * @return The integer error code for this SQLException. The meaning of the + * code is specific to the vendor of the database. + */ + public int getErrorCode() { + return vendorCode; + } + + /** + * Retrieves the SQLException chained to this SQLException, if any. + * + * @return The SQLException chained to this SQLException. null if there is + * no SQLException chained to this SQLException. + */ + public SQLException getNextException() { + return next; + } + + /** + * Retrieves the SQLState description string for this SQLException object + * + * @return The SQLState string for this SQLException object. This is an + * error description string which follows either the SQL 99 + * conventions or the XOPEN SQLstate conventions. The potential + * values of the SQLState string are described in each of the + * specifications. Which of the conventions is being used by the + * SQLState string can be discovered by using the getSQLStateType + * method of the DatabaseMetaData interface. + */ + public String getSQLState() { + return SQLState; + } + + /** + * Adds the SQLException to the end of this SQLException chain. + * + * @param ex + * the new SQLException to be added to the end of the chain + */ + public void setNextException(SQLException ex) { + if (next != null) { + next.setNextException(ex); + } else { + next = ex; + } + } +} Propchange: db/derby/code/trunk/java/stubs/jdbc3/java/sql/SQLException.java ------------------------------------------------------------------------------ svn:eol-style = native Added: db/derby/code/trunk/java/stubs/jdbc3/java/sql/SQLInput.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/stubs/jdbc3/java/sql/SQLInput.java?rev=724735&view=auto ============================================================================== --- db/derby/code/trunk/java/stubs/jdbc3/java/sql/SQLInput.java (added) +++ db/derby/code/trunk/java/stubs/jdbc3/java/sql/SQLInput.java Tue Dec 9 07:06:09 2008 @@ -0,0 +1,280 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package java.sql; + +import java.math.BigDecimal; +import java.io.Reader; +import java.io.InputStream; +import java.net.URL; + +/** + * The SQLInput interface defines operations which apply to a type of input + * stream which carries a series of values which represent an instance of an SQL + * structured type or SQL distinct type. + *

+ * SQLInput interface is used for custom mapping of SQL User Defined Types + * (UDTs)to Java classes. It is used by JDBC drivers below the level of the + * public interfaces and application programs do not normally use the SQLInput + * methods directly. Reader methods such as readLong and readBytes provide means + * to read values from an SQLInput stream. + *

+ * When the getObject method is called with an object which implements the + * SQLData interface, the JDBC driver determines the SQL type of the UDT being + * mapped by calling the SQLData.getSQLType method. The driver creates an + * instance of an SQLInput stream, filling the stream with the attributes of the + * UDT. The SQLInput stream is passed to the SQLData.readSQL method which then + * calls the SQLInput reader methods to read the attributes. + */ +public interface SQLInput { + + /** + * Returns the next attribute in the stream in the form of a String. + * + * @return the next attribute as a String. null if the value is SQL NULL. + * @throws SQLException + * if there is a database error + */ + public String readString() throws SQLException; + + /** + * Returns the next attribute in the stream in the form of a boolean. + * + * @return the next attribute as a boolean. false if the value is SQL NULL. + * @throws SQLException + * if there is a database error + */ + public boolean readBoolean() throws SQLException; + + /** + * Returns the next attribute in the stream in the form of a byte. + * + * @return the next attribute as a byte. 0 if the value is SQL NULL. + * @throws SQLException + * if there is a database error + */ + public byte readByte() throws SQLException; + + /** + * Returns the next attribute in the stream in the form of a short. + * + * @return the next attribute as a short. 0 if the value is SQL NULL. + * @throws SQLException + * if there is a database error + */ + public short readShort() throws SQLException; + + /** + * Returns the next attribute in the stream in the form of an int. + * + * @return the next attribute as an int. 0 if the value is SQL NULL. + * @throws SQLException + * if there is a database error + */ + public int readInt() throws SQLException; + + /** + * Returns the next attribute in the stream in the form of a long. + * + * @return the next attribute as a long. 0 if the value is SQL NULL. + * @throws SQLException + * if there is a database error + */ + public long readLong() throws SQLException; + + /** + * Returns the next attribute in the stream in the form of a float. + * + * @return the next attribute as a float. 0 if the value is SQL NULL. + * @throws SQLException + * if there is a database error + */ + public float readFloat() throws SQLException; + + /** + * Returns the next attribute in the stream in the form of a double. + * + * @return the next attribute as a double. 0 if the value is SQL NULL. + * @throws SQLException + * if there is a database error + */ + public double readDouble() throws SQLException; + + /** + * Returns the next attribute in the stream in the form of a + * java.math.BigDecimal. + * + * @return the attribute as a java.math.BigDecimal. null if the read returns + * SQL NULL. + * @throws SQLException + * if there is a database error + */ + public BigDecimal readBigDecimal() throws SQLException; + + /** + * Returns the next attribute in the stream in the form of a byte array. + * + * @return the attribute as a byte array. null if the read returns SQL NULL. + * @throws SQLException + * if there is a database error + */ + public byte[] readBytes() throws SQLException; + + /** + * Returns the next attribute in the stream in the form of a java.sql.Date. + * + * @return the next attribute as a java.sql.Date. null if the value is SQL + * NULL. + * @throws SQLException + * if there is a database error + */ + public Date readDate() throws SQLException; + + /** + * Returns the next attribute in the stream in the form of a java.sql.Time. + * + * @return the attribute as a java.sql.Time. null if the read returns SQL + * NULL. + * @throws SQLException + * if there is a database error + */ + public Time readTime() throws SQLException; + + /** + * Returns the next attribute in the stream in the form of a + * java.sql.Timestamp. + * + * @return the attribute as a java.sql.Timestamp. null if the read returns + * SQL NULL. + * @throws SQLException + * if there is a database error + */ + public Timestamp readTimestamp() throws SQLException; + + /** + * Returns the next attribute in the stream in the form of a Unicode + * character stream embodied as a java.io.Reader. + * + * @return the next attribute as a java.io.Reader. null if the value is SQL + * NULL. + * @throws SQLException + * if there is a database error + */ + public Reader readCharacterStream() throws SQLException; + + /** + * Returns the next attribute in the stream in the form of an ASCII + * character stream embodied as a java.io.InputStream. + * + * @return the next attribute as a java.io.InputStream. null if the value is + * SQL NULL. + * @throws SQLException + * if there is a database error + */ + public InputStream readAsciiStream() throws SQLException; + + /** + * Returns the next attribute in the stream in the form of a stream of bytes + * embodied as a java.io.InputStream. + * + * @return the next attribute as a java.io.InputStream. null if the value is + * SQL NULL. + * @throws SQLException + * if there is a database error + */ + public InputStream readBinaryStream() throws SQLException; + + /** + * Returns the next attribute in the stream in the form of a + * java.lang.Object. + *

+ * The type of the Object returned is determined by the type mapping for + * this JDBC driver, including any customized mappings in force. A type map + * is given to the SQLInput by the JDBC driver before the SQLInput is given + * to the application. + *

+ * If the attribute is an SQL structured or distinct type, its SQL type is + * determined. If the streams type map contains an element for that SQL + * type, the driver creates an object of relevant type and invokes the + * method SQLData.readSQL on it, which reads supplementary data from the + * stream using whichever protocol is defined for that method. + * + * @return the next attribute as an Object. null if the value is SQL NULL. + * @throws SQLException + * if there is a database error + */ + public Object readObject() throws SQLException; + + /** + * Returns the next attribute in the stream in the form of a java.sql.Ref. + * + * @return the next attribute as a java.sql.Ref. null if the value is SQL + * NULL. + * @throws SQLException + * if there is a database error + */ + public Ref readRef() throws SQLException; + + /** + * Returns the next attribute in the stream in the form of a java.sql.Blob. + * + * @return the next attribute as a java.sql.Blob. null if the value is SQL + * NULL. + * @throws SQLException + * if there is a database error + */ + public Blob readBlob() throws SQLException; + + /** + * Returns the next attribute in the stream in the form of a java.sql.Clob. + * + * @return the next attribute as a java.sql.Clob. null if the value is SQL + * NULL. + * @throws SQLException + * if there is a database error + */ + public Clob readClob() throws SQLException; + + /** + * Returns the next attribute in the stream in the form of a java.sql.Array. + * + * @return the next attribute as an Array. null if the value is SQL NULL. + * @throws SQLException + * if there is a database error + */ + public Array readArray() throws SQLException; + + /** + * Reports whether the last value read was SQL NULL. + * + * @return true if the last value read was SQL NULL, false otherwise. + * @throws SQLException + * if there is a database error + */ + public boolean wasNull() throws SQLException; + + /** + * Reads the next attribute in the stream (SQL DATALINK value) and returns + * it as a java.net.URL object. + * + * @return the next attribute as a java.net.URL. null if the value is SQL + * NULL. + * @throws SQLException + * if there is a database error + */ + public URL readURL() throws SQLException; +} Propchange: db/derby/code/trunk/java/stubs/jdbc3/java/sql/SQLInput.java ------------------------------------------------------------------------------ svn:eol-style = native Added: db/derby/code/trunk/java/stubs/jdbc3/java/sql/SQLOutput.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/stubs/jdbc3/java/sql/SQLOutput.java?rev=724735&view=auto ============================================================================== --- db/derby/code/trunk/java/stubs/jdbc3/java/sql/SQLOutput.java (added) +++ db/derby/code/trunk/java/stubs/jdbc3/java/sql/SQLOutput.java Tue Dec 9 07:06:09 2008 @@ -0,0 +1,280 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package java.sql; + +import java.io.InputStream; +import java.io.Reader; +import java.math.BigDecimal; +import java.net.URL; + +/** + * The interface for an output stream used to write attributes of an SQL User + * Defined Type to the database. This interface is used for custom mapping of + * types and is called by the JDBC driver. It is not expected that this + * interface is used by applications. + *

+ * When an object which implements the SQLData interface is used as an argument + * to an SQL statement, the JDBC driver calls the method + * SQLData.getSQLType to establish the type of the SQL UDT that + * is being passed. The driver then creates an SQLOutput stream and passes it to + * the SQLData.writeSQL method, which in turn uses the + * appropriate SQLOutput writer methods to write the data from the SQLData + * object into the stream according to the defined mapping. + */ +public interface SQLOutput { + + /** + * Write a String value into the output stream. + * + * @param theString + * the String to write + * @throws SQLException + * if a database error occurs + */ + public void writeString(String theString) throws SQLException; + + /** + * Write a boolean value into the output stream. + * + * @param theFlag + * the boolean value to write + * @throws SQLException + * if a database error occurs + */ + public void writeBoolean(boolean theFlag) throws SQLException; + + /** + * Write a byte value into the output stream. + * + * @param theByte + * the byte value to write + * @throws SQLException + * if a database error occurs + */ + public void writeByte(byte theByte) throws SQLException; + + /** + * Write a short value into the output stream. + * + * @param theShort + * the short value to write + * @throws SQLException + * if a database error occurs + */ + public void writeShort(short theShort) throws SQLException; + + /** + * Write an int value into the output stream. + * + * @param theInt + * the int value to write + * @throws SQLException + * if a database error occurs + */ + public void writeInt(int theInt) throws SQLException; + + /** + * Write a long value into the output stream. + * + * @param theLong + * the long value to write + * @throws SQLException + * if a database error occurs + */ + public void writeLong(long theLong) throws SQLException; + + /** + * Write a float value into the output stream. + * + * @param theFloat + * the float value to write + * @throws SQLException + * if a database error occurs + */ + public void writeFloat(float theFloat) throws SQLException; + + /** + * Write a double value into the output stream. + * + * @param theDouble + * the double value to write + * @throws SQLException + * if a database error occurs + */ + public void writeDouble(double theDouble) throws SQLException; + + /** + * Write a java.math.BigDecimal value into the output stream. + * + * @param theBigDecimal + * the BigDecimal value to write + * @throws SQLException + * if a database error occurs + */ + public void writeBigDecimal(BigDecimal theBigDecimal) throws SQLException; + + /** + * Write an array of bytes into the output stream. + * + * @param theBytes + * the array of bytes to write + * @throws SQLException + * if a database error occurs + */ + public void writeBytes(byte[] theBytes) throws SQLException; + + /** + * Write a java.sql.Date value into the output stream. + * + * @param theDate + * the Date value to write + * @throws SQLException + * if a database error occurs + */ + public void writeDate(Date theDate) throws SQLException; + + /** + * Write a java.sql.Time value into the output stream. + * + * @param theTime + * the Time value to write + * @throws SQLException + * if a database error occurs + */ + public void writeTime(Time theTime) throws SQLException; + + /** + * Write a java.sql.Timestamp value into the output stream. + * + * @param theTimestamp + * the Timestamp value to write + * @throws SQLException + * if a database error occurs + */ + public void writeTimestamp(Timestamp theTimestamp) throws SQLException; + + /** + * Write a stream of Unicode characters into the output stream. + * + * @param theStream + * the stream of Unicode characters to write, as a java.io.Reader + * object + * @throws SQLException + * if a database error occurs + */ + public void writeCharacterStream(Reader theStream) throws SQLException; + + /** + * Write a stream of ASCII characters into the output stream. + * + * @param theStream + * the stream of ASCII characters to write, as a + * java.io.InputStream object + * @throws SQLException + * if a database error occurs + */ + public void writeAsciiStream(InputStream theStream) throws SQLException; + + /** + * Write a stream of uninterpreted bytes into the output stream. + * + * @param theStream + * the stream of bytes to write, as a java.io.InputStream object + * @throws SQLException + * if a database error occurs + */ + public void writeBinaryStream(InputStream theStream) throws SQLException; + + /** + * Write an SQLData object into the output stream. + *

+ * If the SQLData object is null, writes SQL NULL to the stream. + *

+ * Otherwise, calls the SQLData.writeSQL method of the + * object, which writes the object's attributes to the stream by calling the + * appropriate SQLOutput writer methods for each attribute, in order. The + * order of the attributes is the order they are listed in the SQL + * definition of the User Defined Type. + * + * @param theObject + * the SQLData object to write + * @throws SQLException + * if a database error occurs + */ + public void writeObject(SQLData theObject) throws SQLException; + + /** + * Write an SQL Ref value into the output stream. + * + * @param theRef + * the java.sql.Ref object to write + * @throws SQLException + * if a database error occurs + */ + public void writeRef(Ref theRef) throws SQLException; + + /** + * Write an SQL Blob value into the output stream. + * + * @param theBlob + * the java.sql.Blob object to write + * @throws SQLException + * if a database error occurs + */ + public void writeBlob(Blob theBlob) throws SQLException; + + /** + * Write an SQL Clob value into the output stream. + * + * @param theClob + * the java.sql.Clob object to write + * @throws SQLException + * if a database error occurs + */ + public void writeClob(Clob theClob) throws SQLException; + + /** + * Write an SQL Struct value into the output stream. + * + * @param theStruct + * the java.sql.Struct object to write + * @throws SQLException + * if a database error occurs + */ + public void writeStruct(Struct theStruct) throws SQLException; + + /** + * Write an SQL Array value into the output stream. + * + * @param theArray + * the java.sql.Array object to write + * @throws SQLException + * if a database error occurs + */ + public void writeArray(Array theArray) throws SQLException; + + /** + * Write an SQL DATALINK value into the output stream. + * + * @param theURL + * the Datalink value as a java.net.URL to write + * @throws SQLException + * if a database error occurs + */ + public void writeURL(URL theURL) throws SQLException; +} Propchange: db/derby/code/trunk/java/stubs/jdbc3/java/sql/SQLOutput.java ------------------------------------------------------------------------------ svn:eol-style = native Added: db/derby/code/trunk/java/stubs/jdbc3/java/sql/SQLPermission.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/stubs/jdbc3/java/sql/SQLPermission.java?rev=724735&view=auto ============================================================================== --- db/derby/code/trunk/java/stubs/jdbc3/java/sql/SQLPermission.java (added) +++ db/derby/code/trunk/java/stubs/jdbc3/java/sql/SQLPermission.java Tue Dec 9 07:06:09 2008 @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package java.sql; + +import java.io.Serializable; +import java.security.BasicPermission; +import java.security.Guard; + +/** + * Permission relating to security access control in the java.sql package. + *

+ * Currently, the only permission supported has the name "setLog". The setLog + * permission controls whether a Java application or applet can open a logging + * stream using the DriverManager.setLogWriter method or the + * DriverManager.setLogStream method. This is a potentially dangerous operation + * since the logging stream can contain usernames, passwords + */ +public final class SQLPermission extends BasicPermission implements Guard, + Serializable { + + private static final long serialVersionUID = -1439323187199563495L; + + /** + * Creates a new SQLPermission object with the specified name. + * + * @param name + * the name to use for this SQLPermission + */ + public SQLPermission(String name) { + super(name); + } + + /** + * Creates a new SQLPermission object with the specified name. + * + * @param name + * is the name of the SQLPermission. Currently only "setLog" is + * allowed. + * @param actions + * is currently unused and should be set to null + */ + public SQLPermission(String name, String actions) { + super(name, null); + } +} Propchange: db/derby/code/trunk/java/stubs/jdbc3/java/sql/SQLPermission.java ------------------------------------------------------------------------------ svn:eol-style = native Added: db/derby/code/trunk/java/stubs/jdbc3/java/sql/SQLWarning.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/stubs/jdbc3/java/sql/SQLWarning.java?rev=724735&view=auto ============================================================================== --- db/derby/code/trunk/java/stubs/jdbc3/java/sql/SQLWarning.java (added) +++ db/derby/code/trunk/java/stubs/jdbc3/java/sql/SQLWarning.java Tue Dec 9 07:06:09 2008 @@ -0,0 +1,92 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package java.sql; + +import java.io.Serializable; + +/** + * An exception class that holds information about Database access warnings. + */ +public class SQLWarning extends SQLException implements Serializable { + + private static final long serialVersionUID = 3917336774604784856L; + + /** + * Creates an SQLWarning object. The Reason string is set to null, the + * SQLState string is set to null and the Error Code is set to 0. + */ + public SQLWarning() { + super(); + } + + /** + * Creates an SQLWarning object. The Reason string is set to the given + * reason string, the SQLState string is set to null and the Error Code is + * set to 0. + * + * @param theReason + */ + public SQLWarning(String theReason) { + super(theReason); + } + + /** + * Creates an SQLWarning object. The Reason string is set to the given + * reason string, the SQLState string is set to the given SQLState string + * and the Error Code is set to 0. + * + * @param theReason + * the string to use as the Reason string + * @param theSQLState + * the string to use as the SQLState string + */ + public SQLWarning(String theReason, String theSQLState) { + super(theReason, theSQLState); + } + + /** + * Creates an SQLWarning object. The Reason string is set to the given + * reason string, the SQLState string is set to the given SQLState string + * and the Error Code is set to the given ErrorCode value. + * + * @param theReason + * @param theSQLState + * @param theErrorCode + */ + public SQLWarning(String theReason, String theSQLState, int theErrorCode) { + super(theReason, theSQLState, theErrorCode); + } + + /** + * Gets the SQLWarning chained to this SQLWarning object. + * + * @return the SQLWarning chained to this SQLWarning. null if no SQLWarning + * is chained to this SQLWarning. + */ + public SQLWarning getNextWarning() { return null; } + + /** + * Chains a supplied SQLWarning to this SQLWarning. + * + * @param w + * the SQLWarning to chain to this SQLWarning. + */ + public void setNextWarning(SQLWarning w) { + super.setNextException(w); + } +} Propchange: db/derby/code/trunk/java/stubs/jdbc3/java/sql/SQLWarning.java ------------------------------------------------------------------------------ svn:eol-style = native Added: db/derby/code/trunk/java/stubs/jdbc3/java/sql/Savepoint.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/stubs/jdbc3/java/sql/Savepoint.java?rev=724735&view=auto ============================================================================== --- db/derby/code/trunk/java/stubs/jdbc3/java/sql/Savepoint.java (added) +++ db/derby/code/trunk/java/stubs/jdbc3/java/sql/Savepoint.java Tue Dec 9 07:06:09 2008 @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package java.sql; + +/** + * A Savepoint is an instant during the current transaction that can be utilized + * by a Rollback from the Connection.rollback method. Rolling back to a + * particular Savepoint means that all changes that occurred after that + * Savepoint are removed. + */ +public interface Savepoint { + + /** + * Returns the constructed ID for this Savepoint. + * + * @return the ID for this Savepoint. + * @throws SQLException + */ + public int getSavepointId() throws SQLException; + + /** + * Returns the name for this Savepoint. + * + * @return the name of this Savepoint. + * @throws SQLException + */ + public String getSavepointName() throws SQLException; +} Propchange: db/derby/code/trunk/java/stubs/jdbc3/java/sql/Savepoint.java ------------------------------------------------------------------------------ svn:eol-style = native Added: db/derby/code/trunk/java/stubs/jdbc3/java/sql/Statement.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/stubs/jdbc3/java/sql/Statement.java?rev=724735&view=auto ============================================================================== --- db/derby/code/trunk/java/stubs/jdbc3/java/sql/Statement.java (added) +++ db/derby/code/trunk/java/stubs/jdbc3/java/sql/Statement.java Tue Dec 9 07:06:09 2008 @@ -0,0 +1,620 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package java.sql; + +/** + * Interface used for executing static SQL statements and returning their + * results. + * + * By default, an object implementing the Statement interface can returns + * results as ResultSets. For any given Statement object, only one ResultSet can + * be open at one time. A call to any of the execution methods of Statement will + * cause any previously created ResultSet object for that Statement to be closed + * implicitly. + *

+ * To have multiple ResultSet objects open concurrently, multiple Statement + * objects must be used. + */ +public interface Statement { + + /** + * Passing this constant to getMoreResults implies that all ResultSet + * objects previously kept open should be closed. + */ + public static final int CLOSE_ALL_RESULTS = 3; + + /** + * Passing this constant to getMoreResults implies that the current + * ResultSet object should be closed + */ + public static final int CLOSE_CURRENT_RESULT = 1; + + /** + * Indicates that an error was encountered during execution of a batch + * statement. + */ + public static final int EXECUTE_FAILED = -3; + + /** + * Passing this constant to getMoreResults implies that the current + * ResultSet object should not be closed. + */ + public static final int KEEP_CURRENT_RESULT = 2; + + /** + * Indicates that generated keys should not be accessible for retrieval. + */ + public static final int NO_GENERATED_KEYS = 2; + + /** + * Indicates that generated keys should be accessible for retrieval. + */ + public static final int RETURN_GENERATED_KEYS = 1; + + /** + * Indicates that a batch statement was executed with a successful result, + * but a count of the number of rows it affected is unavailable. + */ + public static final int SUCCESS_NO_INFO = -2; + + /** + * Adds a specified SQL commands to the list of commands for this Statement. + *

+ * The list of commands is executed by invoking the + * executeBatch method. + * + * @param sql + * the SQL command as a String. Typically an INSERT or UPDATE + * statement. + * @throws SQLException + * if an error occurs accessing the database or the database + * does not support batch updates + */ + public void addBatch(String sql) throws SQLException; + + /** + * Cancels this Statement execution if both the database and the JDBC driver + * support aborting an SQL statement in flight. This method can be used by + * one thread to stop a Statement that is being executed on another thread. + * + * @throws SQLException + * if an error occurs accessing the database + */ + public void cancel() throws SQLException; + + /** + * Clears the current list of SQL commands for this Statement. + * + * @throws SQLException + * if an error occurs accessing the database or the database + * does not support batch updates + */ + public void clearBatch() throws SQLException; + + /** + * Clears all SQLWarnings from this Statement. + * + * @throws SQLException + * if an error occurs accessing the database + */ + public void clearWarnings() throws SQLException; + + /** + * Releases this Statement's database and JDBC driver resources. + *

+ * Using this method to release these resources as soon as possible is + * strongly recommended. It is not a good idea to rely on these resources + * being released when the Statement object is finalized during garbage + * collection. Doing so can result in unpredictable performance + * characteristics for the application. + * + * @throws SQLException + * if an error occurs accessing the database + */ + public void close() throws SQLException; + + /** + * Executes a supplied SQL statement. This may return multiple ResultSets. + *

+ * Use the getResultSet or getUpdateCount + * methods to get the first result and getMoreResults to get + * any subsequent results. + * + * @param sql + * the SQL statement to execute + * @return true if the first result is a ResultSet, false if the first + * result is an update count or if there is no result + * @throws SQLException + * if an error occurs accessing the database + */ + public boolean execute(String sql) throws SQLException; + + /** + * Executes a supplied SQL statement. This may return multiple ResultSets. + * This method allows control of whether auto-generated Keys should be made + * available for retrieval, if the SQL statement is an INSERT statement. + *

+ * Use the getResultSet or getUpdateCount + * methods to get the first result and getMoreResults to get + * any subsequent results. + * + * @param sql + * the SQL statement to execute + * @param autoGeneratedKeys + * a flag indicating whether to make auto generated keys + * available for retrieval. This parameter must be one of + * Statement.NO_GENERATED_KEYS or Statement.RETURN_GENERATED_KEYS + * @return true if results exists and the first result is a ResultSet, false + * if the first result is an update count or if there is no result + * @throws SQLException + * if an error occurs accessing the database + */ + public boolean execute(String sql, int autoGeneratedKeys) + throws SQLException; + + /** + * Executes the supplied SQL statement. This may return multiple ResultSets. + * This method allows retrieval of auto generated keys specified by the + * supplied array of column indexes, if the SQL statement is an INSERT + * statement. + *

+ * Use the getResultSet or getUpdateCount + * methods to get the first result and getMoreResults to get + * any subsequent results. + * + * @param sql + * the SQL statement to execute + * @param columnIndexes + * an array of indexes of the columns in the inserted row which + * should be made available for retrieval via the + * getGeneratedKeys method. + * @return true if the first result is a ResultSet, false if the first + * result is an update count or if there is no result + * @throws SQLException + * if an error occurs accessing the database + */ + public boolean execute(String sql, int[] columnIndexes) throws SQLException; + + /** + * Executes the supplied SQL statement. This may return multiple ResultSets. + * This method allows retrieval of auto generated keys specified by the + * supplied array of column indexes, if the SQL statement is an INSERT + * statement. + *

+ * Use the getResultSet or getUpdateCount + * methods to get the first result and getMoreResults to get + * any subsequent results. + * + * @param sql + * the SQL statement to execute + * @param columnNames + * an array of column names in the inserted row which should be + * made available for retrieval via the + * getGeneratedKeys method. + * @return true if the first result is a ResultSet, false if the first + * result is an update count or if there is no result + * @throws SQLException + * if an error occurs accessing the database + */ + public boolean execute(String sql, String[] columnNames) + throws SQLException; + + /** + * Submits a batch of SQL commands to the database. Returns an array of + * update counts, if all the commands execute successfully. + *

+ * If one of the commands in the batch fails, this method can throw a + * BatchUpdateException and the JDBC driver may or may not process the + * remaining commands. The JDBC driver must behave consistently with the + * underlying database, either always continuing or never continuing. If the + * driver continues processing, the array of results returned contains the + * same number of elements as there are commands in the batch, with a + * minimum of one of the elements having the EXECUTE_FAILED value. + * + * @return an array of update counts, with one entry for each command in the + * batch. The elements are ordered according to the order in which + * the commands were added to the batch. + *

+ *

    + *
  1. If the value of an element is >=0, the corresponding command + * completed successfully and the value is the update count for that + * command, which is the number of rows in the database affected by + * the command.
  2. + *
  3. If the value is SUCCESS_NO_INFO, the command completed + * successfully but the number of rows affected is unknown. + *
  4. + *
  5. If the value is EXECUTE_FAILED, the command failed. + *
+ * @throws SQLException + * if an error occurs accessing the database + */ + public int[] executeBatch() throws SQLException; + + /** + * Executes a supplied SQL statement. Returns a single ResultSet. + * + * @param sql + * an SQL statement to execute. Typically a SELECT statement + * @return a ResultSet containing the data produced by the SQL statement. + * Never null. + * @throws SQLException + * if an error occurs accessing the database or if the statement + * produces anything other than a single ResultSet + */ + public ResultSet executeQuery(String sql) throws SQLException; + + /** + * Executes the supplied SQL statement. The statement may be an INSERT, + * UPDATE or DELETE statement or a statement which returns nothing. + * + * @param sql + * an SQL statement to execute - an SQL INSERT, UPDATE, DELETE or + * a statement which returns nothing + * @return the count of updated rows, or 0 for a statement that returns + * nothing. + * @throws SQLException + * if an error occurs accessing the database or if the statement + * produces a ResultSet + */ + public int executeUpdate(String sql) throws SQLException; + + /** + * Executes the supplied SQL statement. This method allows control of + * whether auto-generated Keys should be made available for retrieval. + * + * @param sql + * an SQL statement to execute - an SQL INSERT, UPDATE, DELETE or + * a statement which does not return anything. + * @param autoGeneratedKeys + * a flag that indicates whether to allow retrieval of auto + * generated keys. Parameter must be one of + * Statement.RETURN_GENERATED_KEYS or Statement.NO_GENERATED_KEYS + * @return the number of updated rows, or 0 if the statement returns + * nothing. + * @throws SQLException + * if an error occurs accessing the database or if the statement + * produces a ResultSet + */ + public int executeUpdate(String sql, int autoGeneratedKeys) + throws SQLException; + + /** + * Executes the supplied SQL statement. This method allows retrieval of auto + * generated keys specified by the supplied array of column indexes. + * + * @param sql + * an SQL statement to execute - an SQL INSERT, UPDATE, DELETE or + * a statement which returns nothing + * @param columnIndexes + * an array of indexes of the columns in the inserted row which + * should be made available for retrieval via the + * getGeneratedKeys method. + * @return the count of updated rows, or 0 for a statement that returns + * nothing. + * @throws SQLException + * if an error occurs accessing the database or if the statement + * produces a ResultSet + */ + public int executeUpdate(String sql, int[] columnIndexes) + throws SQLException; + + /** + * Executes the supplied SQL statement. This method allows retrieval of auto + * generated keys specified by the supplied array of column names. + * + * @param sql + * an SQL statement to execute - an SQL INSERT, UPDATE, DELETE or + * a statement which returns nothing + * @param columnNames + * an array of column names in the inserted row which should be + * made available for retrieval via the + * getGeneratedKeys method. + * @return the count of updated rows, or 0 for a statement that returns + * nothing. + * @throws SQLException + * if an error occurs accessing the database or if the statement + * produces a ResultSet + */ + public int executeUpdate(String sql, String[] columnNames) + throws SQLException; + + /** + * Gets the Connection that produced this Statement. + * + * @return the Connection + * @throws SQLException + * if an error occurs accessing the database + */ + public Connection getConnection() throws SQLException; + + /** + * Gets the default direction for fetching rows for ResultSets generated + * from this Statement. + * + * @return an integer describing the default fetch direction, one of: + * ResultSet.FETCH_FORWARD, ResultSet.FETCH_REVERSE, + * ResultSet.FETCH_UNKNOWN + * @throws SQLException + * if an error occurs accessing the database + */ + public int getFetchDirection() throws SQLException; + + /** + * Gets the default number of rows for a fetch for the ResultSet objects + * returned from this Statement. + * + * @return the default fetch size for ResultSets produced by this Statement + * @throws SQLException + * if an error occurs accessing the database + */ + public int getFetchSize() throws SQLException; + + /** + * Returns auto generated keys created by executing this Statement. + * + * @return a ResultSet containing the auto generated keys - empty if no keys + * were generated by the Statement + * @throws SQLException + * if an error occurs accessing the database + */ + public ResultSet getGeneratedKeys() throws SQLException; + + /** + * Gets the maximum number of bytes which can be returned for values from + * Character and Binary values in a ResultSet derived from this Statement. + * This limit applies to BINARY, VARBINARY, LONGVARBINARY, CHAR, VARCHAR, + * and LONGVARCHAR types. Any data exceeding the maximum size is abandoned + * without announcement. + * + * @return the current size limit, where 0 means that there is no limit + * @throws SQLException + * if an error occurs accessing the database + */ + public int getMaxFieldSize() throws SQLException; + + /** + * Gets the maximum number of rows that a ResultSet can contain when + * produced from this Statement. If the limit is exceeded, the excess rows + * are discarded silently. + * + * @return the current row limit, where 0 means that there is no limit. + * @throws SQLException + * if an error occurs accessing the database + */ + public int getMaxRows() throws SQLException; + + /** + * Moves to this Statement's next result. Returns true if it is a ResultSet. + * Any current ResultSet objects previously obtained with + * getResultSet() are closed implicitly. + * + * @return true if the next result is a ResultSet, false if the next result + * is not a ResultSet or if there are no more results. Note that if + * there is no more data, this method will return false and + * getUpdateCount will return -1. + * @throws SQLException + * if an error occurs accessing the database + */ + public boolean getMoreResults() throws SQLException; + + /** + * Moves to this Statement's next result. Returns true if the next result is + * a ResultSet. Any current ResultSet objects previously obtained with + * getResultSet() are handled as indicated by a supplied Flag + * parameter. + * + * @param current + * a flag indicating what to do with existing ResultSets. This + * parameter must be one of Statement.CLOSE_ALL_RESULTS, + * Statement.CLOSE_CURRENT_RESULT or + * Statement.KEEP_CURRENT_RESULT. + * @return true if the next result exists and is a ResultSet, false if the + * next result is not a ResultSet or if there are no more results. + * Note that if there is no more data, this method will return false + * and getUpdateCount will return -1. + * @throws SQLException + * if an error occurs accessing the database + */ + public boolean getMoreResults(int current) throws SQLException; + + /** + * Gets the timeout value for Statement execution. The JDBC driver will wait + * up to this value for the execution to complete - after the limit is + * exceeded an SQL Exception is thrown. + * + * @return the current Query Timeout value, where 0 indicates that there is + * no current timeout. + * @throws SQLException + * if an error occurs accessing the database + */ + public int getQueryTimeout() throws SQLException; + + /** + * Gets the current result. Should only be called once per result. + * + * @return the ResultSet for the current result. null if the result is an + * update count or if there are no more results. + * @throws SQLException + * if an error occurs accessing the database + */ + public ResultSet getResultSet() throws SQLException; + + /** + * Gets the concurrency setting for ResultSet objects generated by this + * Statement. + * + * @return ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLE + * @throws SQLException + * if an error occurs accessing the database + */ + public int getResultSetConcurrency() throws SQLException; + + /** + * Gets the cursor hold setting for ResultSet objects generated by this + * Statement. + * + * @return ResultSet.HOLD_CURSORS_OVER_COMMIT or + * ResultSet.CLOSE_CURSORS_AT_COMMIT + * @throws SQLException + * if there is an error while accessing the database + */ + public int getResultSetHoldability() throws SQLException; + + /** + * Gets the ResultSet type setting for ResultSets derived from this + * Statement. + * + * @return ResultSet.TYPE_FORWARD_ONLY for a ResultSet where the cursor can + * only move forward, ResultSet.TYPE_SCROLL_INSENSITIVE for a + * ResultSet which is Scrollable but is not sensitive to changes + * made by others, ResultSet.TYPE_SCROLL_SENSITIVE for a ResultSet + * which is Scrollable but is sensitive to changes made by others + * @throws SQLException + * if there is an error accessing the database + */ + public int getResultSetType() throws SQLException; + + /** + * Gets an update count for the current result if it is not a ResultSet. + * + * @return the current result as an update count. -1 if the current result + * is a ResultSet or if there are no more results + * @throws SQLException + * if an error occurs accessing the database + */ + public int getUpdateCount() throws SQLException; + + /** + * Retrieves the first SQLWarning reported by calls on this Statement. + *

+ * If there are multiple warnings, subsequent warnings are chained to the + * first one. + *

+ * The chain or warnings is cleared each time the Statement is executed. + *

+ * Warnings associated with reads from the ResultSet returned from executing + * a Statement will be attached to the ResultSet, not the Statement object. + * + * @return an SQLWarning, null if there are no warnings + * @throws SQLException + * if an error occurs accessing the database + */ + public SQLWarning getWarnings() throws SQLException; + + /** + * Sets the SQL cursor name. This name is used by subsequent Statement + * execute methods. + *

+ * Cursor names must be unique within one Connection. + *

+ * With the Cursor name set, it can then be utilized in SQL positioned + * update or delete statements to determine the current row in a ResultSet + * generated from this Statement. The positioned update or delete must be + * done with a different Statement than this one. + * + * @param name + * the Cursor name as a String, + * @throws SQLException + * if an error occurs accessing the database + */ + public void setCursorName(String name) throws SQLException; + + /** + * Sets Escape Processing mode. + *

+ * If Escape Processing is on, the JDBC driver will do escape substitution + * on an SQL statement before sending it for execution. This does not apply + * to PreparedStatements since they are processed when created, before this + * method can be called. + * + * @param enable + * true to set escape processing mode on, false to turn it off. + * @throws SQLException + * if an error occurs accessing the database + */ + public void setEscapeProcessing(boolean enable) throws SQLException; + + /** + * Sets the fetch direction - a hint to the JDBC driver about the direction + * of processing of rows in ResultSets created by this Statement. The + * default fetch direction is FETCH_FORWARD. + * + * @param direction + * which fetch direction to use. This parameter should be one of + * ResultSet.FETCH_UNKNOWN, ResultSet.FETCH_FORWARD or + * ResultSet.FETCH_REVERSE + * @throws SQLException + * if there is an error while accessing the database or if the + * fetch direction is unrecognized + */ + public void setFetchDirection(int direction) throws SQLException; + + /** + * Sets the fetch size. This is a hint to the JDBC driver about how many + * rows should be fetched from the database when more are required by + * application processing. + * + * @param rows + * the number of rows that should be fetched. 0 tells the driver + * to ignore the hint. Should be less than + * getMaxRows for this statement. Should not be + * negative. + * @throws SQLException + * if an error occurs accessing the database, or if the rows + * parameter is out of range. + */ + public void setFetchSize(int rows) throws SQLException; + + /** + * Sets the maximum number of bytes for ResultSet columns that contain + * character or binary values. This applies to BINARY, VARBINARY, + * LONGVARBINARY, CHAR, VARCHAR, and LONGVARCHAR fields. Any data exceeding + * the maximum size is abandoned without announcement. + * + * @param max + * the maximum field size in bytes. O means "no limit". + * @throws SQLException + * if an error occurs accessing the database or the max value is + * <0. + */ + public void setMaxFieldSize(int max) throws SQLException; + + /** + * Sets the maximum number of rows that any ResultSet can contain. If the + * number of rows exceeds this value, the additional rows are silently + * discarded. + * + * @param max + * the maximum number of rows. 0 means "no limit". + * @throws SQLException + * if an error occurs accessing the database or if max <0. + */ + public void setMaxRows(int max) throws SQLException; + + /** + * Sets the timeout, in seconds, for queries - how long the driver will + * allow for completion of a Statement execution. If the timeout is + * exceeded, the query will throw an SQLException. + * + * @param seconds + * timeout in seconds. 0 means no timeout ("wait forever") + * @throws SQLException + * if an error occurs accessing the database or if seconds <0. + */ + public void setQueryTimeout(int seconds) throws SQLException; +} Propchange: db/derby/code/trunk/java/stubs/jdbc3/java/sql/Statement.java ------------------------------------------------------------------------------ svn:eol-style = native Added: db/derby/code/trunk/java/stubs/jdbc3/java/sql/Struct.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/stubs/jdbc3/java/sql/Struct.java?rev=724735&view=auto ============================================================================== --- db/derby/code/trunk/java/stubs/jdbc3/java/sql/Struct.java (added) +++ db/derby/code/trunk/java/stubs/jdbc3/java/sql/Struct.java Tue Dec 9 07:06:09 2008 @@ -0,0 +1,66 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package java.sql; + +import java.util.Map; + +/** + * An interface which provides facilities for mapping an SQL structured type to + * Java. The Struct object has a value for each attribute of the SQL structured + * type + */ +public interface Struct { + + /** + * Gets the SQL Type name of the SQL structured type that this Struct + * represents + * + * @return the fully qualified name of SQL structured type + * @throws SQLException + * if a database error occurs + */ + public String getSQLTypeName() throws SQLException; + + /** + * Gets the values of the attributes of this SQL structured type. This + * method uses the type map associated with the Connection for customized + * type mappings. Where there is no entry in the Type Map which matches the + * this structured type, the JDBC driver uses the standard mapping. + * + * @return an Object array containing the attributes, in order + * @throws SQLException + * if a database error occurs + */ + public Object[] getAttributes() throws SQLException; + + /** + * Gets the values of the attributes of this SQL structured type. This + * method uses the supplied type map for customized type mappings. Where + * there is no entry in the Type Map which matches the this structured type, + * the JDBC driver uses the default mapping. The Connection type map is + * never utilized by this method. + * + * @param theMap + * a Map describing how SQL Type names are mapped to classes. + * @return an Object array containing the attributes, in order + * @throws SQLException + * if a database error occurs + */ + public Object[] getAttributes(Map theMap) + throws SQLException; +} Propchange: db/derby/code/trunk/java/stubs/jdbc3/java/sql/Struct.java ------------------------------------------------------------------------------ svn:eol-style = native Added: db/derby/code/trunk/java/stubs/jdbc3/java/sql/Time.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/stubs/jdbc3/java/sql/Time.java?rev=724735&view=auto ============================================================================== --- db/derby/code/trunk/java/stubs/jdbc3/java/sql/Time.java (added) +++ db/derby/code/trunk/java/stubs/jdbc3/java/sql/Time.java Tue Dec 9 07:06:09 2008 @@ -0,0 +1,199 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package java.sql; + +import java.text.SimpleDateFormat; +import java.util.Date; + +/** + * Java representation of an SQL TIME value. Provides functions to aid + * generation and interpretation of JDBC escape format for time values. + * + */ +public class Time extends Date { + + private static final long serialVersionUID = 8397324403548013681L; + + /** + * @deprecated Please use the constructor Time( long ) Constructs a Time + * object using the supplied values for Hour, Minute and Second. + * The Year, Month and Day elements of the Time object are set + * to 1970, January, 1 reflecting the Epoch (Time in + * milliseconds = 0). + *

+ * Any attempt to access the Year, Month or Day elements of a + * Time object will result in an IllegalArgumentException. + *

+ * Result is undefined if any argument is out of bounds. + * @param theHour + * a value from 0 - 23 + * @param theMinute + * a value from 0 - 59 + * @param theSecond + * a value from 0 - 59 + */ + public Time(int theHour, int theMinute, int theSecond) { + super(70, 0, 1, theHour, theMinute, theSecond); + } + + /** + * Constructs a Time object using a supplied time specified in milliseconds + * + * @param theTime + * a Time specified in milliseconds since the Epoch (January 1st + * 1970, 00:00:00.000) + */ + public Time(long theTime) { + super(theTime); + } + + /** + * @deprecated This method is deprecated and must not be used. An SQL Time + * object does not have a Date component. + * @return does not return + * @throws IllegalArgumentException + * if this method is called + */ + public int getDate() { + throw new IllegalArgumentException(); + } + + /** + * @deprecated This method is deprecated and must not be used. An SQL Time + * object does not have a Day component. + * @return does not return + * @throws IllegalArgumentException + * if this method is called + */ + public int getDay() { + throw new IllegalArgumentException(); + } + + /** + * @deprecated This method is deprecated and must not be used. An SQL Time + * object does not have a Month component. + * @return does not return + * @throws IllegalArgumentException + * if this method is called + */ + public int getMonth() { + throw new IllegalArgumentException(); + } + + /** + * @deprecated This method is deprecated and must not be used. An SQL Time + * object does not have a Year component. + * @return does not return + * @throws IllegalArgumentException + * if this method is called + */ + public int getYear() { + throw new IllegalArgumentException(); + } + + /** + * @deprecated This method is deprecated and must not be used. An SQL Time + * object does not have a Date component. + * @throws IllegalArgumentException + * if this method is called + */ + public void setDate(int i) { + throw new IllegalArgumentException(); + } + + /** + * @deprecated This method is deprecated and must not be used. An SQL Time + * object does not have a Month component. + * @throws IllegalArgumentException + * if this method is called + */ + public void setMonth(int i) { + throw new IllegalArgumentException(); + } + + /** + * @deprecated This method is deprecated and must not be used. An SQL Time + * object does not have a Year component. + * @throws IllegalArgumentException + * if this method is called + */ + public void setYear(int i) { + throw new IllegalArgumentException(); + } + + /** + * Sets the time for this Time object to the supplied milliseconds value. + * + * @param time + * A time value expressed as milliseconds since the Epoch. + * Negative values are milliseconds before the Epoch. The Epoch + * is January 1 1970, 00:00:00.000 + */ + public void setTime(long time) { + super.setTime(time); + } + + /** + * Formats the Time as a String in JDBC escape format: hh:mm:ss + * + * @return A String representing the Time value in JDBC escape format: + * HH:mm:ss + */ + public String toString() { + SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); //$NON-NLS-1$ + return dateFormat.format(this); + } + + /** + * Creates a Time object from a String holding a time represented in JDBC + * escape format: hh:mm:ss. + *

+ * An exception occurs if the input string is not in the form of a time in + * JDBC escape format. + * + * @param timeString + * A String representing the time value in JDBC escape format: + * hh:mm:ss + * @return The Time object set to a time corresponding to the given time + * @throws IllegalArgumentException + * if the supplied time string is not in JDBC escape format. + */ + public static Time valueOf(String timeString) { + if (timeString == null) { + throw new IllegalArgumentException(); + } + int firstIndex = timeString.indexOf(':'); + int secondIndex = timeString.indexOf(':', firstIndex + 1); + // secondIndex == -1 means none or only one separator '-' has been + // found. + // The string is separated into three parts by two separator characters, + // if the first or the third part is null string, we should throw + // IllegalArgumentException to follow RI + if (secondIndex == -1 || firstIndex == 0 + || secondIndex + 1 == timeString.length()) { + throw new IllegalArgumentException(); + } + // parse each part of the string + int hour = Integer.parseInt(timeString.substring(0, firstIndex)); + int minute = Integer.parseInt(timeString.substring(firstIndex + 1, + secondIndex)); + int second = Integer.parseInt(timeString.substring(secondIndex + 1, + timeString.length())); + return new Time(hour, minute, second); + } +} Propchange: db/derby/code/trunk/java/stubs/jdbc3/java/sql/Time.java ------------------------------------------------------------------------------ svn:eol-style = native Added: db/derby/code/trunk/java/stubs/jdbc3/java/sql/Timestamp.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/stubs/jdbc3/java/sql/Timestamp.java?rev=724735&view=auto ============================================================================== --- db/derby/code/trunk/java/stubs/jdbc3/java/sql/Timestamp.java (added) +++ db/derby/code/trunk/java/stubs/jdbc3/java/sql/Timestamp.java Tue Dec 9 07:06:09 2008 @@ -0,0 +1,329 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package java.sql; + +import java.text.DecimalFormat; +import java.text.ParsePosition; +import java.text.SimpleDateFormat; +import java.util.Date; + +/** + * A Java representation of the SQL TIMESTAMP type. It provides the capability + * to represent the SQL TIMESTAMP nanosecond value, in addition to the regular + * date/time value which has millisecond resolution. + *

+ * The Timestamp class consists of a regular Date/Time value, where only the + * integral seconds value is stored, plus a nanoseconds value where the + * fractional seconds are stored. + *

+ * The addition of the nanosecond value field to the Timestamp object makes it + * significantly different from the java.util.Date object which it extends. + * Users should be cautious in their use of Timestamp objects and should not + * assume that they are interchangeable with java.util.Date objects when used + * outside the confines of the java.sql package. + * + */ +public class Timestamp extends Date { + + private static final long serialVersionUID = 2745179027874758501L; + + // The nanoseconds time value of the Timestamp + private int nanos; + + /** + * @deprecated Please use the constructor Timestamp( long ) Returns a + * Timestamp corresponding to the time specified by the supplied + * values for Year, Month, Date, Hour, Minutes, Seconds and + * Nanoseconds + * @param theYear + * specified as the year minus 1900 + * @param theMonth + * specified as an integer in the range 0 - 11 + * @param theDate + * specified as an integer in the range 1 - 31 + * @param theHour + * specified as an integer in the range 0 - 23 + * @param theMinute + * specified as an integer in the range 0 - 59 + * @param theSecond + * specified as an integer in the range 0 - 59 + * @param theNano + * which defines the nanosecond value of the timestamp specified + * as an integer in the range 0 - 999,999,999 + * @throws IllegalArgumentException + * if any of the parameters is out of range + */ + public Timestamp(int theYear, int theMonth, int theDate, int theHour, + int theMinute, int theSecond, int theNano) + throws IllegalArgumentException { + super(theYear, theMonth, theDate, theHour, theMinute, theSecond); + if (theNano < 0 || theNano > 999999999) { + throw new IllegalArgumentException(); + } + nanos = theNano; + } + + /** + * Returns a Timestamp object corresponding to the time represented by a + * supplied time value. + * + * @param theTime + * a time value in the format of milliseconds since the Epoch + * (January 1 1970 00:00:00.000 GMT) + */ + public Timestamp(long theTime) { + super(theTime); + /* + * Now set the time for this Timestamp object - which deals with the + * nanosecond value as well as the base time + */ + this.setTime(theTime); + } + + /** + * Returns true if this timestamp object is later than the supplied + * timestamp, otherwise returns false. + * + * @param theTimestamp + * the timestamp to compare with this timestamp object + * @return true if this timestamp object is later than the supplied + * timestamp, false otherwise + */ + public boolean after(Timestamp theTimestamp) { + long thisTime = this.getTime(); + long compareTime = theTimestamp.getTime(); + + // If the time value is later, the timestamp is later + if (thisTime > compareTime) { + return true; + } + // If the time value is earlier, the timestamp is not later + else if (thisTime < compareTime) { + return false; + } + /* + * Otherwise the time values are equal in which case the nanoseconds + * value determines whether this timestamp is later... + */ + else if (this.getNanos() > theTimestamp.getNanos()) { + return true; + } else { + return false; + } + } + + /** + * Returns true if this timestamp object is earlier than the supplied + * timestamp, otherwise returns false. + * + * @param theTimestamp + * the timestamp to compare with this timestamp object + * @return true if this timestamp object is earlier than the supplied + * timestamp, false otherwise + */ + public boolean before(Timestamp theTimestamp) { + long thisTime = this.getTime(); + long compareTime = theTimestamp.getTime(); + + // If the time value is later, the timestamp is later + if (thisTime < compareTime) { + return true; + } + // If the time value is earlier, the timestamp is not later + else if (thisTime > compareTime) { + return false; + } + /* + * Otherwise the time values are equal in which case the nanoseconds + * value determines whether this timestamp is later... + */ + else if (this.getNanos() < theTimestamp.getNanos()) { + return true; + } else { + return false; + } + } + + /** + * Compares this Timestamp object with a supplied Timestamp object + * + * @param theObject + * the timestamp to compare with this timestamp object, passed in + * as an Object + * @return 0 if the two Timestamp objects are equal in time, a value <0 if + * this Timestamp object is before the supplied Timestamp and a + * value >0 if this Timestamp object is after the supplied Timestamp + * @throws ClassCastException + * if the supplied object is not a Timestamp object + */ + public int compareTo(Date theObject) throws ClassCastException { + return this.compareTo((Timestamp) theObject); + } + + /** + * Compares this Timestamp object with a supplied Timestamp object + * + * @param theTimestamp + * the timestamp to compare with this timestamp object, passed in + * as a Timestamp + * @return 0 if the two Timestamp objects are equal in time, a value <0 if + * this Timestamp object is before the supplied Timestamp and a + * value >0 if this Timestamp object is after the supplied Timestamp + */ + public int compareTo(Timestamp theTimestamp) { + int result = super.compareTo(theTimestamp); + if (result == 0) { + int thisNano = this.getNanos(); + int thatNano = theTimestamp.getNanos(); + if (thisNano > thatNano) { + return 1; + } else if (thisNano == thatNano) { + return 0; + } else { + return -1; + } + } + return result; + } + + /** + * Tests to see if this timestamp is equal to a supplied object. + * + * @param theObject + * @return true if this Timestamp object is equal to the supplied Timestamp + * object false if the object is not a Timestamp object or if the + * object is a Timestamp but represents a different instant in time + */ + public boolean equals(Object theObject) { + if (theObject instanceof Timestamp) { + return equals((Timestamp) theObject); + } + return false; + } + + /** + * Tests to see if this timestamp is equal to a supplied timestamp. + * + * @param theTimestamp + * the timestamp to compare with this timestamp object, passed in + * as an Object + * @return true if this Timestamp object is equal to the supplied Timestamp + * object + */ + public boolean equals(Timestamp theTimestamp) { + if (theTimestamp == null) { + return false; + } + return (this.getTime() == theTimestamp.getTime()) + && (this.getNanos() == theTimestamp.getNanos()); + } + + /** + * Gets this Timestamp's nanosecond value + * + * @return The timestamp's nanosecond value, an integer between 0 and + * 999,999,999 + */ + public int getNanos() { + return nanos; + } + + /** + * Returns the time represented by this Timestamp object, as a long value + * containing the number of milliseconds since the Epoch (January 1 1970, + * 00:00:00.000 GMT) + */ + public long getTime() { + long theTime = super.getTime(); + theTime = theTime + (nanos / 1000000); + return theTime; + } + + /** + * Sets the nanosecond value for this timestamp + */ + public void setNanos(int n) throws IllegalArgumentException { + } + + /** + * Sets the time represented by this Timestamp object to the supplied time, + * defined as the number of milliseconds since the Epoch (January 1 1970, + * 00:00:00.000 GMT) + */ + public void setTime(long theTime) { + /* + * Deal with the nanoseconds value. The supplied time is in milliseconds - + * so we must extract the milliseconds value and multiply by 1000000 to + * get nanoseconds. Things are more complex if theTime value is + * negative, since then the time value is the time before the Epoch but + * the nanoseconds value of the Timestamp must be positive - so we must + * take the "raw" milliseconds value and subtract it from 1000 to get to + * the true nanoseconds value Simultaneously, recalculate the time value + * to the exact nearest second and reset the Date time value + */ + int milliseconds = (int) (theTime % 1000); + theTime = theTime - milliseconds; + if (milliseconds < 0) { + theTime = theTime - 1000; + milliseconds = 1000 + milliseconds; + } + super.setTime(theTime); + setNanos(milliseconds * 1000000); + } + + /** + * Returns the timestamp formatted as a String in the JDBC Timestamp Escape + * format, which is of the form "yyyy-mm-dd hh:mm:ss.nnnnnnnnn" + * + * @return A string representing the instant defined by the Timestamp, in + * JDBC Timestamp escape format + */ + public String toString() { return null; } + + /* + * Private method to format the time + */ + private String format(int date, int digits) { + StringBuilder dateStringBuffer = new StringBuilder(String.valueOf(date)); + while (dateStringBuffer.length() < digits) { + dateStringBuffer = dateStringBuffer.insert(0, '0'); + } + return dateStringBuffer.toString(); + } + + /* + * Private method to strip trailing '0' characters from a string. @param + * inputString the starting string @return a string with the trailing zeros + * stripped - will leave a single 0 at the beginning of the string + */ + private String stripTrailingZeros(String inputString) { return null; } + + /** + * Creates a Timestamp object with a time value equal to the time specified + * by a supplied String holding the time in JDBC timestamp escape format, + * which is of the form "yyyy-mm-dd hh:mm:ss.nnnnnnnnn" + * + * @param s + * the String containing a time in JDBC timestamp escape format + * @return A timestamp object with time value as defined by the supplied + * String + */ + public static Timestamp valueOf(String s) throws IllegalArgumentException { return null; } + +} + Propchange: db/derby/code/trunk/java/stubs/jdbc3/java/sql/Timestamp.java ------------------------------------------------------------------------------ svn:eol-style = native