提交 db4ce37e authored 作者: Thomas Mueller's avatar Thomas Mueller

Using the java.sql.Blob or java.sql.Clob interfaces could throw the wrong…

Using the java.sql.Blob or java.sql.Clob interfaces could throw the wrong exception after the object was closed.
上级 9fa0b41a
......@@ -18,7 +18,8 @@ Change Log
<h1>Change Log</h1>
<h2>Next Version (unreleased)</h2>
<ul><li>-
<ul><li>Using the java.sql.Blob or java.sql.Clob interfaces could throw the wrong
exception after the object was closed.
</li></ul>
<h2>Version 1.2.147 (2010-11-21)</h2>
......
......@@ -98,7 +98,9 @@ public class JdbcBlob extends TraceObject implements Blob {
*/
public byte[] getBytes(long pos, int length) throws SQLException {
try {
if (isDebugEnabled()) {
debugCode("getBytes("+pos+", "+length+");");
}
checkClosed();
ByteArrayOutputStream out = new ByteArrayOutputStream();
InputStream in = value.getInputStream();
......@@ -132,6 +134,10 @@ public class JdbcBlob extends TraceObject implements Blob {
*/
public int setBytes(long pos, byte[] bytes) throws SQLException {
try {
if (isDebugEnabled()) {
debugCode("setBytes("+pos+", "+quoteBytes(bytes)+");");
}
checkClosed();
if (pos != 1) {
throw DbException.getInvalidValueException("pos", pos);
}
......@@ -184,6 +190,10 @@ public class JdbcBlob extends TraceObject implements Blob {
*/
public OutputStream setBinaryStream(long pos) throws SQLException {
try {
if (isDebugEnabled()) {
debugCode("setBinaryStream("+pos+");");
}
checkClosed();
if (pos != 1) {
throw DbException.getInvalidValueException("pos", pos);
}
......@@ -223,10 +233,12 @@ public class JdbcBlob extends TraceObject implements Blob {
* @throws SQLException
*/
public long position(byte[] pattern, long start) throws SQLException {
debugCode("position(pattern, "+start+");");
if (isDebugEnabled()) {
debugCode("position("+quoteBytes(pattern)+", "+start+");");
}
if (Constants.BLOB_SEARCH) {
try {
debugCode("position(pattern, " + start + ");");
checkClosed();
if (pattern == null) {
return -1;
}
......@@ -276,10 +288,12 @@ public class JdbcBlob extends TraceObject implements Blob {
* @throws SQLException
*/
public long position(Blob blobPattern, long start) throws SQLException {
if (isDebugEnabled()) {
debugCode("position(blobPattern, "+start+");");
}
if (Constants.BLOB_SEARCH) {
try {
debugCode("position(blobPattern, " + start + ");");
checkClosed();
if (blobPattern == null) {
return -1;
}
......@@ -331,7 +345,7 @@ public class JdbcBlob extends TraceObject implements Blob {
* INTERNAL
*/
public String toString() {
return getTraceObjectName() + ": " + value.getTraceSQL();
return getTraceObjectName() + ": " + value == null ? "null" : value.getTraceSQL();
}
}
......@@ -140,6 +140,10 @@ public class JdbcClob extends TraceObject implements Clob
*/
public Writer setCharacterStream(long pos) throws SQLException {
try {
if (isDebugEnabled()) {
debugCodeCall("setCharacterStream(" + pos + ");");
}
checkClosed();
if (pos != 1) {
throw DbException.getInvalidValueException("pos", pos);
}
......@@ -182,7 +186,9 @@ public class JdbcClob extends TraceObject implements Clob
*/
public String getSubString(long pos, int length) throws SQLException {
try {
if (isDebugEnabled()) {
debugCode("getSubString(" + pos + ", " + length + ");");
}
checkClosed();
if (pos < 1) {
throw DbException.getInvalidValueException("pos", pos);
......@@ -221,6 +227,10 @@ public class JdbcClob extends TraceObject implements Clob
*/
public int setString(long pos, String str) throws SQLException {
try {
if (isDebugEnabled()) {
debugCode("setString(" + pos + ", " + quote(str) + ");");
}
checkClosed();
if (pos != 1) {
throw DbException.getInvalidValueException("pos", pos);
}
......@@ -280,7 +290,7 @@ public class JdbcClob extends TraceObject implements Clob
* INTERNAL
*/
public String toString() {
return getTraceObjectName() + ": " + value.getTraceSQL();
return getTraceObjectName() + ": " + value == null ? "null" : value.getTraceSQL();
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论