Changeset: 52918a8ba35a for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=52918a8ba35a
Modified Files:
        
Branch: default
Log Message:

Merged from Dec2011


diffs (184 lines):

diff --git a/java/ChangeLog.Dec2011 b/java/ChangeLog.Dec2011
--- a/java/ChangeLog.Dec2011
+++ b/java/ChangeLog.Dec2011
@@ -1,3 +1,7 @@
 # ChangeLog file for java
 # This file is updated with Maddlog
 
+* Tue Feb 28 2012 Fabian Groffen <[email protected]>
+- Implemented missing Number types support in
+  PreparedStatement.setObject()
+
diff --git a/java/Makefile.ag b/java/Makefile.ag
--- a/java/Makefile.ag
+++ b/java/Makefile.ag
@@ -27,7 +27,7 @@ JAVA_HOME = @JAVA_HOME@
 ant_distjdbc = {
        COND = HAVE_JAVAJDBC
        DIR = datadir/monetdb/lib
-       FILES = monetdb-mcl-1.7.jar monetdb-jdbc-2.1.jar jdbcclient.jar
+       FILES = monetdb-mcl-1.7.jar monetdb-jdbc-2.2.jar jdbcclient.jar
 }
 
 ant_distmerocontrol = {
diff --git a/java/build.properties b/java/build.properties
--- a/java/build.properties
+++ b/java/build.properties
@@ -19,7 +19,7 @@ MCL_MINOR=7
 # major release number
 JDBC_MAJOR=2
 # minor release number
-JDBC_MINOR=1
+JDBC_MINOR=2
 # an additional identifying string
 JDBC_VER_SUFFIX=Liberica
 # the default port to connect on, if no port given when using SQL
diff --git a/java/pom.xml b/java/pom.xml
--- a/java/pom.xml
+++ b/java/pom.xml
@@ -6,7 +6,7 @@
        <modelVersion>4.0.0</modelVersion>
        <groupId>monetdb</groupId>
        <artifactId>monetdb-jdbc</artifactId>
-       <version>2.1</version>
+       <version>2.2</version>
        <name>monetdb-jdbc</name>
        <description>MonetDB JDBC driver</description>
        <repositories>
diff --git a/java/release.txt b/java/release.txt
--- a/java/release.txt
+++ b/java/release.txt
@@ -1,8 +1,8 @@
 RELEASE NOTES
-MonetDB JDBC driver version 2.1 (Liberica/MCL-1.7)
+MonetDB JDBC driver version 2.2 (Liberica/MCL-1.7)
 Fabian Groffen <[email protected]>
 
-Release date: 2012-02-24
+Release date: 2012-02-28
 
 
 This JDBC driver is designed for use with MonetDB, a main-memory
diff --git a/java/src/nl/cwi/monetdb/jdbc/MonetPreparedStatement.java 
b/java/src/nl/cwi/monetdb/jdbc/MonetPreparedStatement.java
--- a/java/src/nl/cwi/monetdb/jdbc/MonetPreparedStatement.java
+++ b/java/src/nl/cwi/monetdb/jdbc/MonetPreparedStatement.java
@@ -1702,8 +1702,15 @@ public class MonetPreparedStatement
                                default:
                                        throw new SQLException("Conversion not 
allowed", "M1M05");
                        }
-               } else if (x instanceof BigDecimal) {
-                       BigDecimal num = (BigDecimal)x;
+               } else if (x instanceof BigDecimal ||
+                               x instanceof Byte ||
+                               x instanceof Short ||
+                               x instanceof Integer ||
+                               x instanceof Long ||
+                               x instanceof Float ||
+                               x instanceof Double)
+               {
+                       Number num = (Number)x;
                        switch (targetSqlType) {
                                case Types.TINYINT:
                                        setByte(parameterIndex, 
num.byteValue());
@@ -1715,7 +1722,12 @@ public class MonetPreparedStatement
                                        setInt(parameterIndex, num.intValue());
                                break;
                                case Types.BIGINT:
-                                       setLong(parameterIndex, 
num.setScale(scale, BigDecimal.ROUND_HALF_UP).longValue());
+                                       if (x instanceof BigDecimal) {
+                                               BigDecimal bd = (BigDecimal)x;
+                                               setLong(parameterIndex, 
bd.setScale(scale, BigDecimal.ROUND_HALF_UP).longValue());
+                                       } else {
+                                               setLong(parameterIndex, 
num.longValue());
+                                       }
                                break;
                                case Types.REAL:
                                        setFloat(parameterIndex, 
num.floatValue());
@@ -1726,7 +1738,12 @@ public class MonetPreparedStatement
                                break;
                                case Types.DECIMAL:
                                case Types.NUMERIC:
-                                       setBigDecimal(parameterIndex, num);
+                                       if (x instanceof BigDecimal) {
+                                               setBigDecimal(parameterIndex, 
(BigDecimal)x);
+                                       } else {
+                                               setBigDecimal(parameterIndex,
+                                                       new 
BigDecimal(num.doubleValue()));
+                                       }
                                break;
                                case Types.BIT:
                                case Types.BOOLEAN:
@@ -1744,20 +1761,6 @@ public class MonetPreparedStatement
                                default:
                                        throw new SQLException("Conversion not 
allowed", "M1M05");
                        }
-               } else if (x instanceof BigInteger) {
-                       BigInteger num = (BigInteger)x;
-                       switch (targetSqlType) {
-                               case Types.BIGINT:
-                                       setLong(parameterIndex, 
num.longValue());
-                               break;
-                               case Types.CHAR:
-                               case Types.VARCHAR:
-                               case Types.LONGVARCHAR:
-                                       setString(parameterIndex, x.toString());
-                               break;
-                               default:
-                                       throw new SQLException("Conversion not 
allowed", "M1M05");
-                       }
                } else if (x instanceof Boolean) {
                        boolean val = ((Boolean)x).booleanValue();
                        switch (targetSqlType) {
@@ -1803,6 +1806,20 @@ public class MonetPreparedStatement
                                default:
                                        throw new SQLException("Conversion not 
allowed", "M1M05");
                        }
+               } else if (x instanceof BigInteger) {
+                       BigInteger num = (BigInteger)x;
+                       switch (targetSqlType) {
+                               case Types.BIGINT:
+                                       setLong(parameterIndex, 
num.longValue());
+                               break;
+                               case Types.CHAR:
+                               case Types.VARCHAR:
+                               case Types.LONGVARCHAR:
+                                       setString(parameterIndex, x.toString());
+                               break;
+                               default:
+                                       throw new SQLException("Conversion not 
allowed", "M1M05");
+                       }
                } else if (x instanceof byte[]) {
                        switch (targetSqlType) {
                                case Types.BINARY:
@@ -1879,24 +1896,24 @@ public class MonetPreparedStatement
                        setBlob(parameterIndex, (Blob)x);
                } else if (x instanceof Clob) {
                        setClob(parameterIndex, (Clob)x);
-               } else if (x instanceof NClob) {
-                       throw new SQLFeatureNotSupportedException("Operation 
setObject() with object of type NClob currently not supported!", "0A000");
                } else if (x instanceof Struct) {
                        // I have no idea how to do this...
                        throw new SQLFeatureNotSupportedException("Operation 
setObject() with object of type Struct currently not supported!", "0A000");
                } else if (x instanceof Ref) {
                        setRef(parameterIndex, (Ref)x);
+               } else if (x instanceof java.net.URL) {
+                       setURL(parameterIndex, (java.net.URL)x);
                } else if (x instanceof RowId) {
                        setRowId(parameterIndex, (RowId)x);
-               } else if (x instanceof java.net.URL) {
-                       setURL(parameterIndex, (java.net.URL)x);
-               } else if (x instanceof SQLData) {
+               } else if (x instanceof NClob) {
+                       throw new SQLFeatureNotSupportedException("Operation 
setObject() with object of type NClob currently not supported!", "0A000");
+               } else if (x instanceof SQLXML) {
+                       throw new SQLFeatureNotSupportedException("Operation 
setObject() with object of type SQLXML currently not supported!", "0A000");
+               } else if (x instanceof SQLData) { // not in JDBC4.1???
                        // do something with:
                        // ((SQLData)x).writeSQL( [java.sql.SQLOutput] );
                        // needs an SQLOutput stream... bit too far away from 
reality
                        throw new SQLFeatureNotSupportedException("Operation 
setObject() with object of type SQLData currently not supported!", "0A000");
-               } else if (x instanceof SQLXML) {
-                       throw new SQLFeatureNotSupportedException("Operation 
setObject() with object of type SQLXML currently not supported!", "0A000");
                } else {        // java Class
                        throw new SQLFeatureNotSupportedException("Operation 
setObject() with object of type Class currently not supported!", "0A000");
                }
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to