jdk/src/java.sql/share/classes/java/sql/Statement.java
changeset 45126 9c8ac4361d9f
parent 44256 12050b22e372
child 45885 562fed91cd84
equal deleted inserted replaced
45125:36fd126403f0 45126:9c8ac4361d9f
     1 /*
     1 /*
     2  * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
   684      * @return <code>true</code> if the next result is a <code>ResultSet</code>
   684      * @return <code>true</code> if the next result is a <code>ResultSet</code>
   685      *         object; <code>false</code> if it is an update count or there are no
   685      *         object; <code>false</code> if it is an update count or there are no
   686      *         more results
   686      *         more results
   687      * @exception SQLException if a database access error occurs,
   687      * @exception SQLException if a database access error occurs,
   688      * this method is called on a closed <code>Statement</code> or the argument
   688      * this method is called on a closed <code>Statement</code> or the argument
   689          *         supplied is not one of the following:
   689      *         supplied is not one of the following:
   690      *        <code>Statement.CLOSE_CURRENT_RESULT</code>,
   690      *        <code>Statement.CLOSE_CURRENT_RESULT</code>,
   691      *        <code>Statement.KEEP_CURRENT_RESULT</code> or
   691      *        <code>Statement.KEEP_CURRENT_RESULT</code> or
   692      *        <code>Statement.CLOSE_ALL_RESULTS</code>
   692      *        <code>Statement.CLOSE_ALL_RESULTS</code>
   693      *@exception SQLFeatureNotSupportedException if
   693      *@exception SQLFeatureNotSupportedException if
   694      * <code>DatabaseMetaData.supportsMultipleOpenResults</code> returns
   694      * <code>DatabaseMetaData.supportsMultipleOpenResults</code> returns
  1377     /**
  1377     /**
  1378      * Returns a {@code String} enclosed in single quotes. Any occurrence of a
  1378      * Returns a {@code String} enclosed in single quotes. Any occurrence of a
  1379      * single quote within the string will be replaced by two single quotes.
  1379      * single quote within the string will be replaced by two single quotes.
  1380      *
  1380      *
  1381      * <blockquote>
  1381      * <blockquote>
  1382      * <table border = 1 cellspacing=0 cellpadding=5 >
  1382      * <table class="striped" >
  1383      * <caption>Examples of the conversion:</caption>
  1383      * <caption>Examples of the conversion:</caption>
       
  1384      * <thead>
  1384      * <tr><th>Value</th><th>Result</th></tr>
  1385      * <tr><th>Value</th><th>Result</th></tr>
  1385      * <tr> <td align='center'>Hello</td> <td align='center'>'Hello'</td> </tr>
  1386      * </thead>
  1386      * <tr> <td align='center'>G'Day</td> <td align='center'>'G''Day'</td> </tr>
  1387      * <tbody style="text-align:center">
  1387      * <tr> <td align='center'>'G''Day'</td>
  1388      * <tr> <td>Hello</td> <td>'Hello'</td> </tr>
  1388      * <td align='center'>'''G''''Day'''</td> </tr>
  1389      * <tr> <td>G'Day</td> <td>'G''Day'</td> </tr>
  1389      * <tr> <td align='center'>I'''M</td> <td align='center'>'I''''''M'</td>
  1390      * <tr> <td>'G''Day'</td>
       
  1391      * <td>'''G''''Day'''</td> </tr>
       
  1392      * <tr> <td>I'''M</td> <td>'I''''''M'</td>
  1390      * </tr>
  1393      * </tr>
  1391      *
  1394      *
       
  1395      * </tbody>
  1392      * </table>
  1396      * </table>
  1393      * </blockquote>
  1397      * </blockquote>
  1394      * @implNote
  1398      * @implNote
  1395      * JDBC driver implementations may need to provide their own implementation
  1399      * JDBC driver implementations may need to provide their own implementation
  1396      * of this method in order to meet the requirements of the underlying
  1400      * of this method in order to meet the requirements of the underlying
  1444      * <li>{@code identifier} contains a {@code null} character or double quote and is not
  1448      * <li>{@code identifier} contains a {@code null} character or double quote and is not
  1445      * a simple SQL identifier.</li>
  1449      * a simple SQL identifier.</li>
  1446      * <li>The length of {@code identifier} is less than 1 or greater than 128 characters
  1450      * <li>The length of {@code identifier} is less than 1 or greater than 128 characters
  1447      * </ul>
  1451      * </ul>
  1448      * <blockquote>
  1452      * <blockquote>
  1449      * <table border = 1 cellspacing=0 cellpadding=5 >
  1453      * <table class="striped" >
  1450      * <caption>Examples of the conversion:</caption>
  1454      * <caption>Examples of the conversion:</caption>
       
  1455      * <thead>
  1451      * <tr>
  1456      * <tr>
  1452      * <th>identifier</th>
  1457      * <th>identifier</th>
  1453      * <th>alwaysQuote</th>
  1458      * <th>alwaysQuote</th>
  1454      * <th>Result</th></tr>
  1459      * <th>Result</th></tr>
       
  1460      * </thead>
       
  1461      * <tbody>
  1455      * <tr>
  1462      * <tr>
  1456      * <td align='center'>Hello</td>
  1463      * <td>Hello</td>
  1457      * <td align='center'>false</td>
  1464      * <td>false</td>
  1458      * <td align='center'>Hello</td>
  1465      * <td>Hello</td>
  1459      * </tr>
  1466      * </tr>
  1460      * <tr>
  1467      * <tr>
  1461      * <td align='center'>Hello</td>
  1468      * <td>Hello</td>
  1462      * <td align='center'>true</td>
  1469      * <td>true</td>
  1463      * <td align='center'>"Hello"</td>
  1470      * <td>"Hello"</td>
  1464      * </tr>
  1471      * </tr>
  1465      * <tr>
  1472      * <tr>
  1466      * <td align='center'>G'Day</td>
  1473      * <td>G'Day</td>
  1467      * <td align='center'>false</td>
  1474      * <td>false</td>
  1468      * <td align='center'>"G'Day"</td>
  1475      * <td>"G'Day"</td>
  1469      * </tr>
  1476      * </tr>
  1470      * <tr>
  1477      * <tr>
  1471      * <td align='center'>"Bruce Wayne"</td>
  1478      * <td>"Bruce Wayne"</td>
  1472      * <td align='center'>false</td>
  1479      * <td>false</td>
  1473      * <td align='center'>"Bruce Wayne"</td>
  1480      * <td>"Bruce Wayne"</td>
  1474      * </tr>
  1481      * </tr>
  1475      * <tr>
  1482      * <tr>
  1476      * <td align='center'>"Bruce Wayne"</td>
  1483      * <td>"Bruce Wayne"</td>
  1477      * <td align='center'>true</td>
  1484      * <td>true</td>
  1478      * <td align='center'>"Bruce Wayne"</td>
  1485      * <td>"Bruce Wayne"</td>
  1479      * </tr>
  1486      * </tr>
  1480      * <tr>
  1487      * <tr>
  1481      * <td align='center'>GoodDay$</td>
  1488      * <td>GoodDay$</td>
  1482      * <td align='center'>false</td>
  1489      * <td>false</td>
  1483      * <td align='center'>"GoodDay$"</td>
  1490      * <td>"GoodDay$"</td>
  1484      * </tr>
  1491      * </tr>
  1485      * <tr>
  1492      * <tr>
  1486      * <td align='center'>Hello"World</td>
  1493      * <td>Hello"World</td>
  1487      * <td align='center'>false</td>
  1494      * <td>false</td>
  1488      * <td align='center'>SQLException</td>
  1495      * <td>SQLException</td>
  1489      * </tr>
  1496      * </tr>
  1490      * <tr>
  1497      * <tr>
  1491      * <td align='center'>"Hello"World"</td>
  1498      * <td>"Hello"World"</td>
  1492      * <td align='center'>false</td>
  1499      * <td>false</td>
  1493      * <td align='center'>SQLException</td>
  1500      * <td>SQLException</td>
  1494      * </tr>
  1501      * </tr>
       
  1502      * </tbody>
  1495      * </table>
  1503      * </table>
  1496      * </blockquote>
  1504      * </blockquote>
  1497      * @implNote
  1505      * @implNote
  1498      * JDBC driver implementations may need to provide their own implementation
  1506      * JDBC driver implementations may need to provide their own implementation
  1499      * of this method in order to meet the requirements of the underlying
  1507      * of this method in order to meet the requirements of the underlying
  1540      * "_"</li>
  1548      * "_"</li>
  1541      * <li>The string is between 1 and 128 characters in length inclusive</li>
  1549      * <li>The string is between 1 and 128 characters in length inclusive</li>
  1542      * </ul>
  1550      * </ul>
  1543      *
  1551      *
  1544      * <blockquote>
  1552      * <blockquote>
  1545      * <table border = 1 cellspacing=0 cellpadding=5 >
  1553      * <table class="striped" >
  1546      * <caption>Examples of the conversion:</caption>
  1554      * <caption>Examples of the conversion:</caption>
       
  1555      * <thead>
  1547      * <tr>
  1556      * <tr>
  1548      * <th>identifier</th>
  1557      * <th>identifier</th>
  1549      * <th>Simple Identifier</th>
  1558      * <th>Simple Identifier</th>
  1550      *
  1559      * </thead>
       
  1560      *
       
  1561      * <tbody>
  1551      * <tr>
  1562      * <tr>
  1552      * <td align='center'>Hello</td>
  1563      * <td>Hello</td>
  1553      * <td align='center'>true</td>
  1564      * <td>true</td>
  1554      * </tr>
  1565      * </tr>
  1555      * <tr>
  1566      * <tr>
  1556      * <td align='center'>G'Day</td>
  1567      * <td>G'Day</td>
  1557      * <td align='center'>false</td>
  1568      * <td>false</td>
  1558      * </tr>
  1569      * </tr>
  1559      * <tr>
  1570      * <tr>
  1560      * <td align='center'>"Bruce Wayne"</td>
  1571      * <td>"Bruce Wayne"</td>
  1561      * <td align='center'>false</td>
  1572      * <td>false</td>
  1562      * </tr>
  1573      * </tr>
  1563      * <tr>
  1574      * <tr>
  1564      * <td align='center'>GoodDay$</td>
  1575      * <td>GoodDay$</td>
  1565      * <td align='center'>false</td>
  1576      * <td>false</td>
  1566      * </tr>
  1577      * </tr>
  1567      * <tr>
  1578      * <tr>
  1568      * <td align='center'>Hello"World</td>
  1579      * <td>Hello"World</td>
  1569      * <td align='center'>false</td>
  1580      * <td>false</td>
  1570      * </tr>
  1581      * </tr>
  1571      * <tr>
  1582      * <tr>
  1572      * <td align='center'>"Hello"World"</td>
  1583      * <td>"Hello"World"</td>
  1573      * <td align='center'>false</td>
  1584      * <td>false</td>
  1574      * </tr>
  1585      * </tr>
       
  1586      * </tbody>
  1575      * </table>
  1587      * </table>
  1576      * </blockquote>
  1588      * </blockquote>
  1577      * @implNote JDBC driver implementations may need to provide their own
  1589      * @implNote JDBC driver implementations may need to provide their own
  1578      * implementation of this method in order to meet the requirements of the
  1590      * implementation of this method in order to meet the requirements of the
  1579      * underlying datasource.
  1591      * underlying datasource.
  1595     * enclosed in single quotes and prefixed with a upper case letter N.
  1607     * enclosed in single quotes and prefixed with a upper case letter N.
  1596     * Any occurrence of a single quote within the string will be replaced
  1608     * Any occurrence of a single quote within the string will be replaced
  1597     * by two single quotes.
  1609     * by two single quotes.
  1598     *
  1610     *
  1599     * <blockquote>
  1611     * <blockquote>
  1600     * <table border = 1 cellspacing=0 cellpadding=5 >
  1612     * <table class="striped">
  1601     * <caption>Examples of the conversion:</caption>
  1613     * <caption>Examples of the conversion:</caption>
       
  1614     * <thead>
  1602     * <tr>
  1615     * <tr>
  1603     * <th>Value</th>
  1616     * <th>Value</th>
  1604     * <th>Result</th>
  1617     * <th>Result</th>
  1605     * </tr>
  1618     * </tr>
  1606     * <tr> <td align='center'>Hello</td> <td align='center'>N'Hello'</td> </tr>
  1619     * </thead>
  1607     * <tr> <td align='center'>G'Day</td> <td align='center'>N'G''Day'</td> </tr>
  1620     * <tbody>
  1608     * <tr> <td align='center'>'G''Day'</td>
  1621     * <tr> <td>Hello</td> <td>N'Hello'</td> </tr>
  1609     * <td align='center'>N'''G''''Day'''</td> </tr>
  1622     * <tr> <td>G'Day</td> <td>N'G''Day'</td> </tr>
  1610     * <tr> <td align='center'>I'''M</td> <td align='center'>N'I''''''M'</td>
  1623     * <tr> <td>'G''Day'</td>
  1611     * <tr> <td align='center'>N'Hello'</td> <td align='center'>N'N''Hello'''</td> </tr>
  1624     * <td>N'''G''''Day'''</td> </tr>
       
  1625     * <tr> <td>I'''M</td> <td>N'I''''''M'</td>
       
  1626     * <tr> <td>N'Hello'</td> <td>N'N''Hello'''</td> </tr>
  1612     *
  1627     *
       
  1628     * </tbody>
  1613     * </table>
  1629     * </table>
  1614     * </blockquote>
  1630     * </blockquote>
  1615     * @implNote
  1631     * @implNote
  1616     * JDBC driver implementations may need to provide their own implementation
  1632     * JDBC driver implementations may need to provide their own implementation
  1617     * of this method in order to meet the requirements of the underlying
  1633     * of this method in order to meet the requirements of the underlying