diff src/main/java/nl/cwi/monetdb/jdbc/MonetResultSet.java @ 175:8700d9ef2ace

Added possibility via a connection property to let the JDBC driver return columnType value Types.VARCHAR instead of Types.CLOB in case the result column of a ResultSet or parameter in a PreparedStatement is of data type 'clob'. With this connection property set, you can reduce the overhead when working with clob column data from generic JDBC programs.
author Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
date Thu, 28 Sep 2017 16:17:51 +0200 (2017-09-28)
parents 7c9e386fe49a
children fdf4c888d5b7
line wrap: on
line diff
--- a/src/main/java/nl/cwi/monetdb/jdbc/MonetResultSet.java
+++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetResultSet.java
@@ -196,14 +196,21 @@ public class MonetResultSet
 	 * thereby improving getXyz() method performance.
 	 */
 	private void populateJdbcSQLtypesArray() {
+		MonetConnection connection = null;
+		try {
+			connection = (MonetConnection)statement.getConnection();
+		} catch (SQLException se) { /* ignore it */ }
+
 		for (int i = 0; i < types.length; i++) {
 			int javaSQLtype = MonetDriver.getJavaType(types[i]);
 			JdbcSQLTypes[i] = javaSQLtype;
+			if (javaSQLtype == Types.CLOB) {
+				if (connection != null && connection.mapClobAsVarChar())
+					JdbcSQLTypes[i] = Types.VARCHAR;
+			} else
 			if (javaSQLtype == Types.BLOB) {
-				try {
-					if (((MonetConnection)statement.getConnection()).getBlobAsBinary())
-						JdbcSQLTypes[i] = Types.BINARY;
-				} catch (SQLException se) { /* ignore it */ }
+				if (connection != null && connection.mapBlobAsVarBinary())
+					JdbcSQLTypes[i] = Types.VARBINARY;
 			}
 		}
 	}