提交 5c69455f authored 作者: Thomas Mueller's avatar Thomas Mueller

Various CallableStatement methods could throw a NullPointerException.

上级 52f3bd34
......@@ -18,8 +18,12 @@ Change Log
<h1>Change Log</h1>
<h2>Next Version (unreleased)</h2>
<ul><li>LOB files were not deleted when running DROP ALL OBJECTS.
<ul><li>Various CallableStatement methods could throw a NullPointerException.
</li><li>LOB files were not deleted when running DROP ALL OBJECTS.
</li><li>MS SQL Server compatibility: support string literals prefixed with N ("National Language" strings). Issue 240.
</li><li>CAST: when converting a string to binary, it is hex encoded (every byte two characters);
a hex string can be converted to a number by first converting it to binary. Examples:
CAST(CAST('FFFF' AS BINARY) AS INT) = 65535, CAST(65535 AS BINARY) = '0000FFFF'.
</li><li>When a domain (user defined data type) contained a user defined function, the database could not be opened.
</li><li>CAST('011' AS INT) will no longer use decode the value as an octal number (using Integer.decode) but now use Integer.parseInt.
The same logic applied to byte, short, and long. This also means that trying to convert hex numbers (0x...) with CAST now fails.
......
......@@ -945,7 +945,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
*
* @param parameterIndex the parameter index (1, 2, ...)
* @param x the value
* @param length the number of bytes
* @param length the number of characters
* @throws SQLException if this object is closed
*/
public void setCharacterStream(int parameterIndex, Reader x, int length) throws SQLException {
......@@ -972,7 +972,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
*
* @param parameterIndex the parameter index (1, 2, ...)
* @param x the value
* @param length the number of bytes
* @param length the number of characters
* @throws SQLException if this object is closed
*/
public void setCharacterStream(int parameterIndex, Reader x, long length) throws SQLException {
......@@ -1300,7 +1300,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
*
* @param parameterIndex the parameter index (1, 2, ...)
* @param x the value
* @param length the number of bytes
* @param length the number of characters
* @throws SQLException if this object is closed
*/
//## Java 1.6 begin ##
......@@ -1402,6 +1402,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
*
* @param parameterIndex the parameter index (1, 2, ...)
* @param x the value
* @param length the number of characters
* @throws SQLException if this object is closed
*/
public void setClob(int parameterIndex, Reader x, long length) throws SQLException {
......@@ -1454,6 +1455,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
*
* @param parameterIndex the parameter index (1, 2, ...)
* @param x the value
* @param length the number of characters
* @throws SQLException if this object is closed
*/
//## Java 1.6 begin ##
......
......@@ -319,7 +319,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
}
/**
* Returns the value of the specified column as a String.
* Returns the value of the specified column as a BigDecimal.
*
* @param columnIndex (1,2,...)
* @return the value
......@@ -383,11 +383,12 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
}
/**
* Returns the value of the specified column as a String.
* Returns the value of the specified column as a BigDecimal.
*
* @param columnLabel the column label
* @return the value
* @throws SQLException if the column is not found or if the result set is closed
* @throws SQLException if the column is not found or if the result set is
* closed
*/
public BigDecimal getBigDecimal(String columnLabel) throws SQLException {
try {
......@@ -419,7 +420,8 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
*
* @param columnLabel the column label
* @return the value
* @throws SQLException if the column is not found or if the result set is closed
* @throws SQLException if the column is not found or if the result set is
* closed
*/
public Time getTime(String columnLabel) throws SQLException {
try {
......@@ -435,7 +437,8 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
*
* @param columnLabel the column label
* @return the value
* @throws SQLException if the column is not found or if the result set is closed
* @throws SQLException if the column is not found or if the result set is
* closed
*/
public Timestamp getTimestamp(String columnLabel) throws SQLException {
try {
......@@ -691,7 +694,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
}
/**
* Returns the value of the specified column as a String.
* Returns the value of the specified column as a BigDecimal.
*
* @deprecated
*
......@@ -716,7 +719,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
}
/**
* Returns the value of the specified column as a String.
* Returns the value of the specified column as a BigDecimal.
*
* @deprecated
*
......@@ -760,7 +763,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
* [Not supported] Gets a column as a object using the specified type
* mapping.
*/
public Object getObject(int columnIndex, Map<String, Class< ? >> map) throws SQLException {
public Object getObject(int columnIndex, Map<String, Class<?>> map) throws SQLException {
throw unsupported("map");
}
......@@ -990,7 +993,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
}
/**
* Returns the value of the specified column as input stream.
* Returns the value of the specified column as an input stream.
*
* @param columnIndex (1,2,...)
* @return the value
......@@ -1007,7 +1010,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
}
/**
* Returns the value of the specified column as input stream.
* Returns the value of the specified column as an input stream.
*
* @param columnLabel the column label
* @return the value
......@@ -1101,7 +1104,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
}
/**
* Returns the value of the specified column as input stream.
* Returns the value of the specified column as an input stream.
*
* @param columnIndex (1,2,...)
* @return the value
......@@ -1119,7 +1122,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
}
/**
* Returns the value of the specified column as input stream.
* Returns the value of the specified column as an input stream.
*
* @param columnLabel the column label
* @return the value
......@@ -1137,7 +1140,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
}
/**
* Returns the value of the specified column as input stream.
* Returns the value of the specified column as a reader.
*
* @param columnIndex (1,2,...)
* @return the value
......@@ -1154,7 +1157,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
}
/**
* Returns the value of the specified column as input stream.
* Returns the value of the specified column as a reader.
*
* @param columnLabel the column label
* @return the value
......@@ -3286,7 +3289,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
//## Java 1.6 end ##
/**
* Returns the value of the specified column as input stream.
* Returns the value of the specified column as a reader.
*
* @param columnIndex (1,2,...)
* @return the value
......@@ -3305,7 +3308,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
//## Java 1.6 end ##
/**
* Returns the value of the specified column as input stream.
* Returns the value of the specified column as a reader.
*
* @param columnLabel the column label
* @return the value
......
......@@ -14,6 +14,7 @@ import java.sql.Statement;
import java.sql.Timestamp;
import java.sql.Types;
import org.h2.constant.ErrorCode;
import org.h2.test.TestBase;
import org.h2.tools.SimpleResultSet;
......@@ -98,6 +99,23 @@ public class TestCallableStatement extends TestBase {
} catch (SQLException e) {
// expected exception
}
// test for exceptions after closing
call.close();
try {
call.executeUpdate();
} catch (SQLException e) {
assertEquals(ErrorCode.OBJECT_CLOSED, e.getErrorCode());
}
try {
call.registerOutParameter(1, Types.INTEGER);
} catch (SQLException e) {
assertEquals(ErrorCode.OBJECT_CLOSED, e.getErrorCode());
}
try {
call.getURL("X");
} catch (SQLException e) {
assertEquals(ErrorCode.OBJECT_CLOSED, e.getErrorCode());
}
}
/**
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论