提交 53a3af71 authored 作者: Thomas Mueller's avatar Thomas Mueller

ResultSetMetaData.getColumnClassName returned the wrong class for CLOB and BLOB columns.

上级 05e0e57e
...@@ -23,6 +23,7 @@ import java.util.ArrayList; ...@@ -23,6 +23,7 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import org.h2.constant.ErrorCode; import org.h2.constant.ErrorCode;
import org.h2.constant.SysProperties;
import org.h2.engine.Constants; import org.h2.engine.Constants;
import org.h2.engine.SessionInterface; import org.h2.engine.SessionInterface;
import org.h2.jdbc.JdbcBlob; import org.h2.jdbc.JdbcBlob;
...@@ -630,9 +631,17 @@ public class DataType { ...@@ -630,9 +631,17 @@ public class DataType {
// "java.lang.String"; // "java.lang.String";
return String.class.getName(); return String.class.getName();
case Value.BLOB: case Value.BLOB:
if (SysProperties.RETURN_LOB_OBJECTS) {
// "java.sql.Blob";
return java.sql.Blob.class.getName();
}
// "java.io.InputStream"; // "java.io.InputStream";
return java.io.InputStream.class.getName(); return java.io.InputStream.class.getName();
case Value.CLOB: case Value.CLOB:
if (SysProperties.RETURN_LOB_OBJECTS) {
// "java.sql.Clob";
return java.sql.Clob.class.getName();
}
// "java.io.Reader"; // "java.io.Reader";
return java.io.Reader.class.getName(); return java.io.Reader.class.getName();
case Value.DOUBLE: case Value.DOUBLE:
......
...@@ -217,8 +217,13 @@ public class TestMetaData extends TestBase { ...@@ -217,8 +217,13 @@ public class TestMetaData extends TestBase {
stat.execute("INSERT INTO t VALUES('', '')"); stat.execute("INSERT INTO t VALUES('', '')");
ResultSet rs = stat.executeQuery("SELECT blob,clob FROM t"); ResultSet rs = stat.executeQuery("SELECT blob,clob FROM t");
ResultSetMetaData meta = rs.getMetaData(); ResultSetMetaData meta = rs.getMetaData();
assertEquals("java.io.InputStream", meta.getColumnClassName(1)); if (SysProperties.RETURN_LOB_OBJECTS) {
assertEquals("java.io.Reader", meta.getColumnClassName(2)); assertEquals("java.sql.Blob", meta.getColumnClassName(1));
assertEquals("java.sql.Clob", meta.getColumnClassName(2));
} else {
assertEquals("java.io.InputStream", meta.getColumnClassName(1));
assertEquals("java.io.Reader", meta.getColumnClassName(2));
}
rs.next(); rs.next();
if (SysProperties.RETURN_LOB_OBJECTS) { if (SysProperties.RETURN_LOB_OBJECTS) {
assertTrue(rs.getObject(1) instanceof java.sql.Blob); assertTrue(rs.getObject(1) instanceof java.sql.Blob);
......
...@@ -20,6 +20,7 @@ import java.sql.Time; ...@@ -20,6 +20,7 @@ import java.sql.Time;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.sql.Types; import java.sql.Types;
import org.h2.constant.SysProperties;
import org.h2.test.TestBase; import org.h2.test.TestBase;
/** /**
...@@ -228,9 +229,13 @@ public class TestUpdatableResultSet extends TestBase { ...@@ -228,9 +229,13 @@ public class TestUpdatableResultSet extends TestBase {
assertEquals(meta.getColumnClassName(12), "java.lang.Long"); assertEquals(meta.getColumnClassName(12), "java.lang.Long");
assertEquals(meta.getColumnClassName(13), "java.lang.Integer"); assertEquals(meta.getColumnClassName(13), "java.lang.Integer");
assertEquals(meta.getColumnClassName(14), "java.lang.Short"); assertEquals(meta.getColumnClassName(14), "java.lang.Short");
assertEquals(meta.getColumnClassName(15), "java.io.Reader"); if (SysProperties.RETURN_LOB_OBJECTS) {
assertEquals(meta.getColumnClassName(16), "java.io.InputStream"); assertEquals(meta.getColumnClassName(15), "java.sql.Clob");
assertEquals(meta.getColumnClassName(16), "java.sql.Blob");
} else {
assertEquals(meta.getColumnClassName(15), "java.io.Reader");
assertEquals(meta.getColumnClassName(16), "java.io.InputStream");
}
rs.moveToInsertRow(); rs.moveToInsertRow();
rs.updateInt(1, 0); rs.updateInt(1, 0);
rs.updateNull(2); rs.updateNull(2);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论