提交 591a799e authored 作者: Thomas Mueller's avatar Thomas Mueller

Issue 334: SimpleResultSet.getString now also works for Clob columns.

上级 f478beb6
......@@ -28,6 +28,7 @@ import java.util.Calendar;
import java.util.Map;
import org.h2.constant.ErrorCode;
import org.h2.message.DbException;
import org.h2.util.MathUtils;
import org.h2.util.New;
import org.h2.value.DataType;
......@@ -472,7 +473,15 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
*/
public String getString(int columnIndex) throws SQLException {
Object o = get(columnIndex);
return o == null ? null : o.toString();
if (o == null) {
return null;
}
switch (columns.get(columnIndex - 1).sqlType) {
case Types.CLOB:
Clob c = (Clob) o;
return c.getSubString(1, MathUtils.convertLongToInt(c.length()));
}
return o.toString();
}
/**
......
......@@ -79,6 +79,7 @@ public class TestTools extends TestBase {
return;
}
org.h2.Driver.load();
testSimpleResultSet();
testTcpServerWithoutPort();
testConsole();
testJdbcDriverUtils();
......@@ -99,7 +100,6 @@ public class TestTools extends TestBase {
testScriptRunscript();
testBackupRestore();
testRecover();
testSimpleResultSet();
deleteDb("utils");
FileUtils.delete(getBaseDir() + "/b2.sql");
FileUtils.delete(getBaseDir() + "/b2.sql.txt");
......@@ -293,6 +293,8 @@ public class TestTools extends TestBase {
assertTrue(clob == rs.getClob("k"));
assertTrue(clob == rs.getClob(11));
assertEquals("Hello World", rs.getString("k"));
assertEquals("Hello World", rs.getString(11));
assertTrue(blob == rs.getBlob("l"));
assertTrue(blob == rs.getBlob(12));
......@@ -910,7 +912,7 @@ public class TestTools extends TestBase {
}
public String getSubString(long pos, int length) throws SQLException {
throw new UnsupportedOperationException();
return data;
}
public long length() throws SQLException {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论