2 files changed
+25
No files matched your search
@@ -19,6 +19,7 @@ import com.dbx.agent.TableInfo;
|
||||
import com.dbx.agent.TriggerInfo;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Types;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
@@ -389,6 +390,10 @@ public final class Db2Agent extends AbstractJdbcAgent {
|
||||
@Override
|
||||
protected Object resultValue(ResultSet rs, int index, int sqlType) {
|
||||
return unchecked(() -> {
|
||||
if (sqlType == Types.CLOB || sqlType == Types.NCLOB) {
|
||||
String value = rs.getString(index);
|
||||
return rs.wasNull() ? null : value;
|
||||
}
|
||||
Object value = rs.getObject(index);
|
||||
return rs.wasNull() ? null : value == null ? null : value.toString();
|
||||
});
|
||||
|
||||
@@ -18,6 +18,7 @@ import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
import java.sql.Types;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
@@ -50,6 +51,25 @@ class Db2AgentTest extends JdbcFakeExecutionBehaviorTest {
|
||||
assertEquals("jdbc:db2://db.example.com:50000/SAMPLE:sslConnection=true;", Db2Agent.buildUrl(params));
|
||||
}
|
||||
|
||||
@Test
|
||||
void readsClobValuesAsTextInsteadOfVendorObjectNames() {
|
||||
Db2Agent agent = new Db2Agent();
|
||||
ResultSet resultSet = proxy(ResultSet.class, new MethodHandler() {
|
||||
@Override
|
||||
public Object handle(Method method, Object[] args) {
|
||||
if ("getString".equals(method.getName())) {
|
||||
return "long text value";
|
||||
}
|
||||
if ("wasNull".equals(method.getName())) {
|
||||
return false;
|
||||
}
|
||||
return defaultValue(method.getReturnType());
|
||||
}
|
||||
});
|
||||
|
||||
assertEquals("long text value", agent.resultValue(resultSet, 1, Types.CLOB));
|
||||
}
|
||||
|
||||
@Test
|
||||
void listsAllCatalogSchemasWithoutOwnerTypeFiltering() {
|
||||
Db2Agent agent = new Db2Agent();
|
||||
|
||||
Reference in new issue
Block a user