< prev index next >
src/java.sql/share/classes/java/sql/Statement.java
Print this page
@@ -40,10 +40,11 @@
* <code>Statement</code> interface implicitly close a current
* <code>ResultSet</code> object of the statement if an open one exists.
*
* @see Connection#createStatement
* @see ResultSet
+ * @since 1.1
*/
public interface Statement extends Wrapper, AutoCloseable {
/**
* Executes the given SQL statement, which returns a single
@@ -1397,10 +1398,12 @@
* @param val a character string
* @return A string enclosed by single quotes with every single quote
* converted to two single quotes
* @throws NullPointerException if val is {@code null}
* @throws SQLException if a database access error occurs
+ *
+ * @since 9
*/
default String enquoteLiteral(String val) throws SQLException {
return "'" + val.replace("'", "''") + "'";
}
@@ -1501,10 +1504,12 @@
* @return A simple SQL identifier or a delimited identifier
* @throws SQLException if identifier is not a valid identifier
* @throws SQLFeatureNotSupportedException if the datasource does not support
* delimited identifiers
* @throws NullPointerException if identifier is {@code null}
+ *
+ * @since 9
*/
default String enquoteIdentifier(String identifier, boolean alwaysQuote) throws SQLException {
int len = identifier.length();
if (len < 1 || len > 128) {
throw new SQLException("Invalid name");
@@ -1574,10 +1579,12 @@
* underlying datasource.
* @param identifier a SQL identifier
* @return true if a simple SQL identifier, false otherwise
* @throws NullPointerException if identifier is {@code null}
* @throws SQLException if a database access error occurs
+ *
+ * @since 9
*/
default boolean isSimpleIdentifier(String identifier) throws SQLException {
int len = identifier.length();
return len >= 1 && len <= 128
&& Pattern.compile("[\\p{Alpha}][\\p{Alnum}_]*").matcher(identifier).matches();
@@ -1615,10 +1622,12 @@
* @return the result of replacing every single quote character in the
* argument by two single quote characters where this entire result is
* then prefixed with 'N'.
* @throws NullPointerException if val is {@code null}
* @throws SQLException if a database access error occurs
+ *
+ * @since 9
*/
default String enquoteNCharLiteral(String val) throws SQLException {
return "N'" + val.replace("'", "''") + "'";
}
}
< prev index next >