Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2011-07-06 03:44:27 -0400
committerEike Stepper2011-07-06 03:44:27 -0400
commitea637f75e42685a7694abf3f9acca7b6cc4f6de2 (patch)
treec07c9675df6382eda9c954213c9508abb553b784 /plugins
parentb9f43a4ac76796d43a34a1c4d67bdd2c032eff8f (diff)
downloadcdo-ea637f75e42685a7694abf3f9acca7b6cc4f6de2.tar.gz
cdo-ea637f75e42685a7694abf3f9acca7b6cc4f6de2.tar.xz
cdo-ea637f75e42685a7694abf3f9acca7b6cc4f6de2.zip
[350036] [DB] Convert CLOB to String in SQLQueryHandler
https://bugs.eclipse.org/bugs/show_bug.cgi?id=350036
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/SQLQueryHandler.java26
1 files changed, 23 insertions, 3 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/SQLQueryHandler.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/SQLQueryHandler.java
index 75887cd6d3..589e7a1ed7 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/SQLQueryHandler.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/SQLQueryHandler.java
@@ -22,6 +22,7 @@ import org.eclipse.emf.cdo.server.db.IIDHandler;
import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBUtil;
+import java.sql.Clob;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
@@ -209,7 +210,7 @@ public class SQLQueryHandler implements IQueryHandler
columnNames[i - 1] = resultSet.getMetaData().getColumnName(i);
}
}
-
+
int maxResults = info.getMaxResults();
int counter = 0;
@@ -230,7 +231,7 @@ public class SQLQueryHandler implements IQueryHandler
int columnCount = resultSet.getMetaData().getColumnCount();
if (columnCount == 1)
{
- Object result = resultSet.getObject(1);
+ Object result = convertValue(resultSet.getObject(1));
context.addResult(mapQuery ? toMap(columnNames, new Object[] { result }) : result);
}
else
@@ -238,7 +239,7 @@ public class SQLQueryHandler implements IQueryHandler
Object[] results = new Object[columnCount];
for (int i = 0; i < columnCount; i++)
{
- results[i] = resultSet.getObject(i + 1);
+ results[i] = convertValue(resultSet.getObject(i + 1));
}
context.addResult(mapQuery ? toMap(columnNames, results) : results);
@@ -263,6 +264,25 @@ public class SQLQueryHandler implements IQueryHandler
}
}
+ private Object convertValue(Object value)
+ {
+ if (value instanceof Clob)
+ {
+ Clob clob = (Clob)value;
+
+ try
+ {
+ value = clob.getSubString(1, (int)clob.length());
+ }
+ catch (SQLException ex)
+ {
+ throw new DBException("Could not extract CLOB value", ex);
+ }
+ }
+
+ return value;
+ }
+
private Map<String, Object> toMap(String[] columnNames, Object[] results)
{
Map<String, Object> ret = new HashMap<String, Object>();

Back to the top