SF.net SVN: jython:[7132] trunk/jython

[email protected] Sun, 03 Oct 2010 21:14:29 +0000
Newsgroups gmane.comp.lang.jython.cvs
Message-ID <[email protected]>
Revision: 7132
          http://jython.svn.sourceforge.net/jython/?rev=7132&view=rev
Author:   otmarhumbel
Date:     2010-10-03 21:14:29 +0000 (Sun, 03 Oct 2010)

Log Message:
-----------
handle the new JDBC 4.0 java.sql.Types as well
(this hopefully really fixes issue 1647)

Modified Paths:
--------------
    trunk/jython/src/com/ziclix/python/sql/DataHandler.java
    trunk/jython/tests/java/com/ziclix/python/sql/DataHandlerTest.java

Modified: trunk/jython/src/com/ziclix/python/sql/DataHandler.java
===================================================================
--- trunk/jython/src/com/ziclix/python/sql/DataHandler.java	2010-10-03 19:47:13 UTC (rev 7131)
+++ trunk/jython/src/com/ziclix/python/sql/DataHandler.java	2010-10-03 21:14:29 UTC (rev 7132)
@@ -236,11 +236,14 @@
 
             case Types.CHAR:
             case Types.VARCHAR:
+            case Java6Types.NCHAR:
+            case Java6Types.NVARCHAR:
                 String string = set.getString(col);
                 obj = string == null ? Py.None : Py.newUnicode(string);
                 break;
 
             case Types.LONGVARCHAR:
+            case Java6Types.LONGNVARCHAR:
                 Reader reader = set.getCharacterStream(col);
                 obj = reader == null ? Py.None : Py.newUnicode(read(reader));
                 break;
@@ -310,6 +313,8 @@
                 break;
 
             case Types.CLOB:
+            case Java6Types.NCLOB:
+            case Java6Types.SQLXML:
                 Clob clob = set.getClob(col);
                 obj = clob == null ? Py.None : Py.java2py(read(clob.getCharacterStream()));
                 break;
@@ -323,6 +328,8 @@
                 throw createUnsupportedTypeSQLException("DISTINCT", col);
             case Types.REF:
                 throw createUnsupportedTypeSQLException("REF", col);
+            case Java6Types.ROWID:
+                throw createUnsupportedTypeSQLException("STRUCT", col);
             case Types.STRUCT:
                 throw createUnsupportedTypeSQLException("STRUCT", col);
                 
@@ -560,5 +567,60 @@
     public String toString() {
         return getClass().getName();
     }
+    
+    /**
+     * This interface can be removed as soon as we target java 6
+     */
+    private static interface Java6Types{
+        /**
+         * The constant in the Java programming language, sometimes referred to
+         * as a type code, that identifies the generic SQL type <code>ROWID</code>
+         * 
+         * @since 1.6
+         *
+         */
+        public final static int ROWID = -8;
+
+        /**
+         * The constant in the Java programming language, sometimes referred to
+         * as a type code, that identifies the generic SQL type <code>NCHAR</code>
+         *
+         * @since 1.6
+         */
+        public static final int NCHAR = -15;
+
+        /**
+         * The constant in the Java programming language, sometimes referred to
+         * as a type code, that identifies the generic SQL type <code>NVARCHAR</code>.
+         *
+         * @since 1.6
+         */
+        public static final int NVARCHAR = -9;
+
+        /**
+         * The constant in the Java programming language, sometimes referred to
+         * as a type code, that identifies the generic SQL type <code>LONGNVARCHAR</code>.
+         *
+         * @since 1.6
+         */
+        public static final int LONGNVARCHAR = -16;
+
+        /**
+         * The constant in the Java programming language, sometimes referred to
+         * as a type code, that identifies the generic SQL type <code>NCLOB</code>.
+         *
+         * @since 1.6
+         */
+        public static final int NCLOB = 2011;
+
+        /**
+         * The constant in the Java programming language, sometimes referred to
+         * as a type code, that identifies the generic SQL type <code>XML</code>.
+         *
+         * @since 1.6 
+         */
+        public static final int SQLXML = 2009;
+    }
+    
 }
 

Modified: trunk/jython/tests/java/com/ziclix/python/sql/DataHandlerTest.java
===================================================================
--- trunk/jython/tests/java/com/ziclix/python/sql/DataHandlerTest.java	2010-10-03 19:47:13 UTC (rev 7131)
+++ trunk/jython/tests/java/com/ziclix/python/sql/DataHandlerTest.java	2010-10-03 21:14:29 UTC (rev 7132)
@@ -39,6 +39,7 @@
                                                       "DATALINK",
                                                       "DISTINCT",
                                                       "REF",
+                                                      "ROWID", // java 6
                                                       "STRUCT");
         for (Field field : Types.class.getDeclaredFields()) {
             String typeName = field.getName();


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.

------------------------------------------------------------------------------
Virtualization is moving to the mainstream and overtaking non-virtualized
environment for deploying applications. Does it make network security 
easier or more difficult to achieve? Read this whitepaper to separate the 
two and get a better understanding.
http://p.sf.net/sfu/hp-phase2-d2d