Changeset: 1db50c40252b for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=1db50c40252b
Modified Files:
        java/ChangeLog.Feb2013
        java/Makefile.ag
        java/build.properties
        java/pom.xml
        java/release.txt
        java/src/nl/cwi/monetdb/jdbc/MonetPreparedStatement.java
        java/tests/Test_PStypes.java
Branch: default
Log Message:

Merge with Feb2013 branch.


diffs (198 lines):

diff --git a/java/ChangeLog.Feb2013 b/java/ChangeLog.Feb2013
--- a/java/ChangeLog.Feb2013
+++ b/java/ChangeLog.Feb2013
@@ -1,3 +1,9 @@
 # ChangeLog file for java
 # This file is updated with Maddlog
 
+* Thu May 23 2013 Fabian Groffen <fab...@monetdb.org>
+- Fixed bug where PreparedStatement.setBigDecimal() wouldn't format its
+  input well enough for the server causing odd errors.
+- Allow PreparedStatement.setXXX() methods to be called with null
+  arguments, bug #3288
+
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.9.jar monetdb-jdbc-2.8.jar jdbcclient.jar
+       FILES = monetdb-mcl-1.9.jar monetdb-jdbc-2.9.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=9
 # major release number
 JDBC_MAJOR=2
 # minor release number
-JDBC_MINOR=8
+JDBC_MINOR=9
 # 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.8</version>
+       <version>2.9</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.8 (Liberica/MCL-1.9)
+MonetDB JDBC driver version 2.9 (Liberica/MCL-1.9)
 Fabian Groffen <fab...@monetdb.org>
 
-Release date: 2012-12-01
+Release date: 2013-05-23
 
 
 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
@@ -951,14 +951,25 @@ public class MonetPreparedStatement
         * The driver converts this to an SQL NUMERIC value when it sends it to 
the
         * database.
         *
-        * @param parameterIndex the first parameter is 1, the second is 2, ...
+        * @param i the first parameter is 1, the second is 2, ...
         * @param x the parameter value
         * @throws SQLException if a database access error occurs
         */
-       public void setBigDecimal(int parameterIndex, BigDecimal x)
+       public void setBigDecimal(int i, BigDecimal x)
                throws SQLException
        {
-               setValue(parameterIndex, x.toString());
+               // if we don't give the server the exact digits/scale thing, it
+               // barfs at us that we don't give it a correct value, so...
+               String ps = x.toPlainString();
+               // chop off excess "precision"
+               int di = ps.indexOf(".");
+               if (di >= 0 && ps.length() - di - 1 > scale[i])
+                       ps = ps.substring(0, di + scale[i] + (scale[i] == 0 ? 0 
: 1));
+               if (di < 0)
+                       di = ps.length();
+               if (di > (digits[i] - scale[i]))
+                       throw new SQLDataException("DECIMAL value exceeds 
allowed digits/scale: " + ps + " (" + digits[i] + "/" + scale[i] + ")", 
"22003");
+               setValue(i, ps);
        }
 
        /**
@@ -1155,6 +1166,11 @@ public class MonetPreparedStatement
                int length)
                throws SQLException
        {
+               if (reader == null) {
+                       setNull(parameterIndex, -1);
+                       return;
+               }
+
                CharBuffer tmp = CharBuffer.allocate(length);
                try {
                        reader.read(tmp);
@@ -1223,6 +1239,11 @@ public class MonetPreparedStatement
         * @throws SQLException if a database access error occurs
         */
        public void setClob(int i, Clob x) throws SQLException {
+               if (x == null) {
+                       setNull(i, -1);
+                       return;
+               }
+
                // simply serialise the CLOB into a variable for now... far from
                // efficient, but might work for a few cases...
                // be on your marks: we have to cast the length down!
@@ -1262,6 +1283,11 @@ public class MonetPreparedStatement
         * @throws SQLException if a database access error occurs
         */
        public void setClob(int i, Reader reader, long length) throws 
SQLException {
+               if (reader == null) {
+                       setNull(i, -1);
+                       return;
+               }
+
                // simply serialise the CLOB into a variable for now... far from
                // efficient, but might work for a few cases...
                CharBuffer buf = CharBuffer.allocate((int)length); // have to 
down cast :(
@@ -1306,6 +1332,11 @@ public class MonetPreparedStatement
        public void setDate(int parameterIndex, java.sql.Date x, Calendar cal)
                throws SQLException
        {
+               if (x == null) {
+                       setNull(parameterIndex, -1);
+                       return;
+               }
+
                if (cal == null) {
                        setValue(parameterIndex, "date '" + x.toString() + "'");
                } else {
@@ -2098,6 +2129,11 @@ public class MonetPreparedStatement
         * @throws SQLException if a database access error occurs
         */
        public void setString(int parameterIndex, String x) throws SQLException 
{
+               if (x == null) {
+                       setNull(parameterIndex, -1);
+                       return;
+               }
+
                setValue(
                        parameterIndex,
                        "'" + x.replaceAll("\\\\", "\\\\\\\\").replaceAll("'", 
"\\\\'") + "'"
@@ -2150,6 +2186,11 @@ public class MonetPreparedStatement
        public void setTime(int index, Time x, Calendar cal)
                throws SQLException
        {
+               if (x == null) {
+                       setNull(index, -1);
+                       return;
+               }
+
                boolean hasTimeZone = 
monetdbType[getParamIdx(index)].endsWith("tz");
                if (hasTimeZone) {
                        // timezone shouldn't matter, since the server is 
timezone
@@ -2205,6 +2246,11 @@ public class MonetPreparedStatement
        public void setTimestamp(int index, Timestamp x, Calendar cal)
                throws SQLException
        {
+               if (x == null) {
+                       setNull(index, -1);
+                       return;
+               }
+
                boolean hasTimeZone = 
monetdbType[getParamIdx(index)].endsWith("tz");
                if (hasTimeZone) {
                        // timezone shouldn't matter, since the server is 
timezone
diff --git a/java/tests/Test_PStypes.java b/java/tests/Test_PStypes.java
--- a/java/tests/Test_PStypes.java
+++ b/java/tests/Test_PStypes.java
@@ -76,12 +76,13 @@ public class Test_PStypes {
 
                        // try an update like bug #1757923
                        pstmt = con.prepareStatement(
-"UPDATE HTMTEST set COMMENT=? WHERE HTMID=?"
+"UPDATE HTMTEST set COMMENT=?, TYPE=? WHERE HTMID=?"
 );
                        System.out.print("2. updating record...");
 
                        pstmt.setString(1, "some update");
-                       pstmt.setLong(2, 1L);
+                       pstmt.setObject(2, (float)3.2);
+                       pstmt.setLong(3, 1L);
                        pstmt.executeUpdate();
 
                        System.out.println("success :)");
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to