# HG changeset patch
# User Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
# Date 1552588910 -3600
# Node ID 9c1ecdbbd9aa4d2285feab760e48edb2be074412
# Parent  ee4c826e39335c4325072556a66959e8c35c4e39
Extend getColumnClassName() by also checking the connection's typeMap for Class names for types url and inet. Similar code as used in getParameterClassName().
Improve ParameterMetaData.isSigned() to return more correct value in case the parameter type is oid or ptr. Similar code as used in ResultSetMetaData.isSigned().
Improve ParameterMetaData.getParameterMode() to return ParameterMetaData.parameterModeIn as we currently only support INput parameters for prepared statements.

diff --git a/src/main/java/nl/cwi/monetdb/jdbc/MonetPreparedStatement.java b/src/main/java/nl/cwi/monetdb/jdbc/MonetPreparedStatement.java
--- a/src/main/java/nl/cwi/monetdb/jdbc/MonetPreparedStatement.java
+++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetPreparedStatement.java
@@ -45,7 +45,7 @@ import java.util.Map;
  *
  * This implementation of the PreparedStatement interface uses the
  * capabilities of the MonetDB/SQL backend to prepare and execute
- * queries.  The backend takes care of finding the '?'s in the input and
+ * statements.  The backend takes care of finding the '?'s in the input and
  * returns the types it expects for them.
  *
  * An example of a server response on a prepare query is:
@@ -690,7 +690,15 @@ public class MonetPreparedStatement
 			 */
 			@Override
 			public String getColumnClassName(int column) throws SQLException {
-				return MonetResultSet.getClassForType(getColumnType(column)).getName();
+				String typeName = getColumnTypeName(column);
+				Map<String,Class<?>> map = getConnection().getTypeMap();
+				Class<?> c;
+				if (map.containsKey(typeName)) {
+					c = (Class)map.get(typeName);
+				} else {
+					c = MonetResultSet.getClassForType(getColumnType(column));
+				}
+				return c.getName();
 			}
 
 			/**
@@ -789,7 +797,6 @@ public class MonetPreparedStatement
 					if (column[i] == null)
 						cnt++;
 				}
-
 				return cnt;
 			}
 
@@ -828,11 +835,18 @@ public class MonetPreparedStatement
 					case Types.TINYINT:
 					case Types.SMALLINT:
 					case Types.INTEGER:
-					case Types.BIGINT:
 					case Types.REAL:
 					case Types.FLOAT:
 					case Types.DOUBLE:
 						return true;
+					case Types.BIGINT:
+						String monettype = getParameterTypeName(param);
+						if (monettype != null) {
+							if ("oid".equals(monettype)
+							 || "ptr".equals(monettype))
+								return false;
+						}
+						return true;
 					case Types.BIT: // we don't use type BIT, it's here for completeness
 					case Types.BOOLEAN:
 					case Types.DATE:
@@ -940,7 +954,7 @@ public class MonetPreparedStatement
 
 			/**
 			 * Retrieves the designated parameter's mode.
-			 * For MonetDB/SQL this is currently always unknown.
+			 * For MonetDB/SQL we currently only support INput parameters.
 			 *
 			 * @param param - the first parameter is 1, the second is 2, ...
 			 * @return mode of the parameter; one of
@@ -952,7 +966,7 @@ public class MonetPreparedStatement
 			 */
 			@Override
 			public int getParameterMode(int param) throws SQLException {
-				return ParameterMetaData.parameterModeUnknown;
+				return ParameterMetaData.parameterModeIn;
 			}
 		};
 	}