2 files changed
+34
No files matched your search
@@ -113,6 +113,19 @@ public final class DamengAgent extends AbstractJdbcAgent {
|
||||
private URLClassLoader externalDriverLoader;
|
||||
private List<URL> externalDriverUrls;
|
||||
private String externalDriverClass;
|
||||
|
||||
@Override
|
||||
protected JdbcExecutor.ResultValueReader resultValueReader() {
|
||||
return (JdbcExecutor.ColumnAwareResultValueReader) this::readDamengValue;
|
||||
}
|
||||
|
||||
private Object readDamengValue(ResultSet resultSet, int index, int sqlType, String columnTypeName) throws SQLException {
|
||||
if ("VARCHAR2".equalsIgnoreCase(columnTypeName == null ? "" : columnTypeName.trim())) {
|
||||
String value = resultSet.getString(index);
|
||||
return resultSet.wasNull() ? null : value;
|
||||
}
|
||||
return super.resultValue(resultSet, index, sqlType);
|
||||
}
|
||||
private volatile boolean legacyJdbcMetadata;
|
||||
private volatile boolean dbmsOutputInitializationSupported = true;
|
||||
private final Map<Object, Boolean> dbmsOutputInitializedConnections =
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.dbx.agent.dameng;
|
||||
import com.dbx.agent.DatabaseAgent;
|
||||
import com.dbx.agent.ExecuteQueryOptions;
|
||||
import com.dbx.agent.IndexInfo;
|
||||
import com.dbx.agent.JdbcExecutor;
|
||||
import com.dbx.agent.MetadataListConstraints;
|
||||
import com.dbx.agent.QueryPageOptions;
|
||||
import com.dbx.agent.QueryPageResult;
|
||||
@@ -18,10 +19,12 @@ import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.SQLFeatureNotSupportedException;
|
||||
import java.sql.SQLTransientConnectionException;
|
||||
import java.sql.Statement;
|
||||
import java.sql.Types;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -60,6 +63,24 @@ class DamengAgentTest extends JdbcFakeExecutionBehaviorTest {
|
||||
assertEquals(List.of("executeQuery"), JdbcAgentFake.calls);
|
||||
}
|
||||
|
||||
@Test
|
||||
void readsVarchar2AsTextWhenDriverReportsNumericSqlType() throws Exception {
|
||||
DamengAgent agent = new DamengAgent();
|
||||
ResultSet resultSet = (ResultSet) Proxy.newProxyInstance(
|
||||
ResultSet.class.getClassLoader(),
|
||||
new Class<?>[] {ResultSet.class},
|
||||
(proxy, method, args) -> switch (method.getName()) {
|
||||
case "getString" -> "001";
|
||||
case "wasNull" -> false;
|
||||
default -> defaultValue(method.getReturnType());
|
||||
}
|
||||
);
|
||||
|
||||
JdbcExecutor.ColumnAwareResultValueReader reader = (JdbcExecutor.ColumnAwareResultValueReader) agent.resultValueReader();
|
||||
|
||||
assertEquals("001", reader.read(resultSet, 1, Types.NUMERIC, "VARCHAR2"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void physicalConnectionsDoNotEnableDbmsOutput() throws Exception {
|
||||
List<String> executedSql = new ArrayList<>();
|
||||
|
||||
Reference in new issue
Block a user