Skip to content
38 changes: 29 additions & 9 deletions src/java.sql/share/classes/java/sql/Array.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -61,13 +61,19 @@
* If the connection's type map or a type map supplied to a method has no entry
* for the base type, the elements are mapped according to the standard mapping.
* <p>
* To release resources used by the {@code Array} object, applications must call
* either the {@link #free()} or the {@link #close()} method. Any attempt to
* invoke a method other than {@link #free()} or {@link #close()} after the
* {@code Array} object has been closed, will result in a {@link SQLException}
* being thrown.
* <P>
* All methods on the {@code Array} interface must be fully implemented if the
* JDBC driver supports the data type.
*
* @since 1.2
*/

public interface Array {
public interface Array extends AutoCloseable {

/**
* Retrieves the SQL type name of the elements in
Expand Down Expand Up @@ -345,21 +351,35 @@ ResultSet getResultSet (long index, int count,
java.util.Map<String,Class<?>> map)
throws SQLException;
/**
* This method frees the {@code Array} object and releases the resources that
* it holds. The object is invalid once the {@code free}
* method is called.
* Closes and releases the resources held by this {@code Array} object.
* <p>
* After {@code free} has been called, any attempt to invoke a
* method other than {@code free} will result in a {@code SQLException}
* being thrown. If {@code free} is called multiple times, the subsequent
* calls to {@code free} are treated as a no-op.
* If the {@code Array} object is already closed, then invoking this method
* has no effect.
*
* @throws SQLException if an error occurs releasing
* the Array's resources
* @throws SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.6
* @see #close()
*/
void free() throws SQLException;

/**
* Closes and releases the resources held by this {@code Array} object.
* <p>
* If the {@code Array} object is already closed, then invoking this method
* has no effect.
*
* @throws SQLException if an error occurs releasing
* the Array's resources
* @throws SQLFeatureNotSupportedException if the JDBC driver
* does not support this method
* @implSpec The default implementation calls the {@link #free()} method.
* @see #free()
* @since 26
*/
default void close() throws SQLException {
free();
};
}
42 changes: 32 additions & 10 deletions src/java.sql/share/classes/java/sql/Blob.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -32,7 +32,7 @@
* the Java programming language of an SQL
* {@code BLOB} value. An SQL {@code BLOB} is a built-in type
* that stores a Binary Large Object as a column value in a row of
* a database table. By default drivers implement {@code Blob} using
* a database table. By default, drivers implement {@code Blob} using
* an SQL {@code locator(BLOB)}, which means that a
* {@code Blob} object contains a logical pointer to the
* SQL {@code BLOB} data rather than the data itself.
Expand All @@ -50,13 +50,19 @@
* {@code BLOB} value. In addition, this interface has methods for updating
* a {@code BLOB} value.
* <p>
* To release resources used by the {@code Blob} object, applications must call
* either the {@link #free()} or the {@link #close()} method. Any attempt to
* invoke a method other than {@link #free()} or {@link #close()} after the
* {@code Blob} object has been closed, will result in a {@link SQLException}
* being thrown.
* <P>
* All methods on the {@code Blob} interface must be fully implemented if the
* JDBC driver supports the data type.
*
* @since 1.2
*/

public interface Blob {
public interface Blob extends AutoCloseable {

/**
* Returns the number of bytes in the {@code BLOB} value
Expand Down Expand Up @@ -266,20 +272,17 @@ public interface Blob {
void truncate(long len) throws SQLException;

/**
* This method frees the {@code Blob} object and releases the resources that
* it holds. The object is invalid once the {@code free}
* method is called.
* Closes and releases the resources held by this {@code Blob} object.
* <p>
* After {@code free} has been called, any attempt to invoke a
* method other than {@code free} will result in an {@code SQLException}
* being thrown. If {@code free} is called multiple times, the subsequent
* calls to {@code free} are treated as a no-op.
* If the {@code Blob} object is already closed, then invoking this method
* has no effect.
*
* @throws SQLException if an error occurs releasing
* the Blob's resources
* @throws SQLFeatureNotSupportedException if the JDBC driver
* does not support this method
* @since 1.6
* @see #close()
*/
void free() throws SQLException;

Expand All @@ -303,4 +306,23 @@ public interface Blob {
* @since 1.6
*/
InputStream getBinaryStream(long pos, long length) throws SQLException;

/**
* Closes and releases the resources held by this {@code Blob} object.
* <p>
* If the {@code Blob} object is already closed, then invoking this method
* has no effect.
*
* @implSpec The default implementation calls the {@link #free()} method.
*
* @throws SQLException if an error occurs releasing
* the Blob's resources
* @throws SQLFeatureNotSupportedException if the JDBC driver
* does not support this method
* @since 26
* @see #free()
*/
default void close() throws SQLException {
free();
};
}
40 changes: 30 additions & 10 deletions src/java.sql/share/classes/java/sql/Clob.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -33,7 +33,7 @@
* An SQL {@code CLOB} is a built-in type
* that stores a Character Large Object as a column value in a row of
* a database table.
* By default drivers implement a {@code Clob} object using an SQL
* By default, drivers implement a {@code Clob} object using an SQL
* {@code locator(CLOB)}, which means that a {@code Clob} object
* contains a logical pointer to the SQL {@code CLOB} data rather than
* the data itself. A {@code Clob} object is valid for the duration
Expand All @@ -49,13 +49,19 @@
* access an SQL {@code CLOB} value. In addition, this interface
* has methods for updating a {@code CLOB} value.
* <p>
* To release resources used by the {@code Clob} object, applications must call
* either the {@link #free()} or the {@link #close()} method. Any attempt to
* invoke a method other than {@link #free()} or {@link #close()} after the
* {@code Clob} object has been closed, will result in a {@link SQLException}
* being thrown.
* <P>
* All methods on the {@code Clob} interface must be
* fully implemented if the JDBC driver supports the data type.
*
* @since 1.2
*/

public interface Clob {
public interface Clob extends AutoCloseable {

/**
* Retrieves the number of characters
Expand Down Expand Up @@ -310,21 +316,18 @@ public interface Clob {
void truncate(long len) throws SQLException;

/**
* This method releases the resources that the {@code Clob} object
* holds. The object is invalid once the {@code free} method
* is called.
* Closes and releases the resources held by this {@code Clob} object.
* <p>
* After {@code free} has been called, any attempt to invoke a
* method other than {@code free} will result in a {@code SQLException}
* being thrown. If {@code free} is called multiple times, the subsequent
* calls to {@code free} are treated as a no-op.
* If the {@code Clob} object is already closed, then invoking this method
* has no effect.
*
* @throws SQLException if an error occurs releasing
* the Clob's resources
*
* @throws SQLFeatureNotSupportedException if the JDBC driver
* does not support this method
* @since 1.6
* @see #close()
*/
void free() throws SQLException;

Expand All @@ -350,4 +353,21 @@ public interface Clob {
*/
Reader getCharacterStream(long pos, long length) throws SQLException;

/**
* Closes and releases the resources held by this {@code Clob} object.
* <p>
* If the {@code Clob} object is already closed, then invoking this method
* has no effect.
*
* @throws SQLException if an error occurs releasing
* the Clob's resources
* @throws SQLFeatureNotSupportedException if the JDBC driver
* does not support this method
* @implSpec The default implementation calls the {@link #free()} method.
* @see #free()
* @since 26
*/
default void close() throws SQLException {
free();
};
}
Loading