[libgda] JDBC provider corrections



commit 99e2150e1f59bdc85117d140f221720a8428e2c6
Author: Vivien Malerba <malerba gnome-db org>
Date:   Thu Apr 25 18:29:07 2013 +0200

    JDBC provider corrections
    
    - handle deprecated functions
    - corrected compilation
    - misc.

 providers/jdbc/GdaJValue.c          |   14 +++++++-------
 providers/jdbc/Makefile.am          |   10 ++++++----
 providers/jdbc/gda-jdbc-provider.c  |    2 +-
 providers/jdbc/gda-jdbc-recordset.c |    4 ++--
 providers/jdbc/jni-wrapper.c        |    6 +++++-
 providers/jdbc/libmain.c            |   23 ++++++++++++++++++++++-
 providers/jdbc/provider.java        |   15 ++++++++-------
 7 files changed, 51 insertions(+), 23 deletions(-)
---
diff --git a/providers/jdbc/GdaJValue.c b/providers/jdbc/GdaJValue.c
index 70c19d0..c115ffb 100644
--- a/providers/jdbc/GdaJValue.c
+++ b/providers/jdbc/GdaJValue.c
@@ -110,13 +110,13 @@ JNICALL Java_GdaJValue_setCChar (G_GNUC_UNUSED JNIEnv *jenv, G_GNUC_UNUSED jobje
 {
        GValue *value = gda_row_get_value (GDA_ROW ((gpointer) c_pointer), col);
        gda_value_reset_with_type (value, G_TYPE_CHAR);
-       g_value_set_char (value, b);
+       g_value_set_schar (value, b);
 }
 
 JNIEXPORT jbyte
 JNICALL Java_GdaJValue_getCChar (G_GNUC_UNUSED JNIEnv *jenv, G_GNUC_UNUSED jobject obj, jlong c_pointer)
 {
-       return (jbyte) g_value_get_char ((GValue *) c_pointer);
+       return (jbyte) g_value_get_schar ((GValue *) c_pointer);
 }
 
 JNIEXPORT void
@@ -492,10 +492,10 @@ JNICALL Java_GdaJValue_setCNumeric (JNIEnv *jenv, G_GNUC_UNUSED jobject obj, jlo
                g_free (tmp);
                return;
        }
-       num = g_new0 (GdaNumeric, 1);
-       num->number = tmp;
-       num->precision = precision;
-       num->width = scale;
+       num = gda_numeric_new ();
+       gda_numeric_set_from_string (num, tmp);
+       gda_numeric_set_precision (num, precision);
+       gda_numeric_set_width (num, scale);
        gda_value_reset_with_type (value, GDA_TYPE_NUMERIC);
        g_value_take_boxed (value, num);
 }
@@ -531,7 +531,7 @@ JNICALL Java_GdaJValue_getCNumeric (JNIEnv *jenv, G_GNUC_UNUSED jobject obj, jlo
        if ((*jenv)->ExceptionCheck (jenv))
                return NULL;
 
-       string = (*jenv)->NewStringUTF (jenv, num->number);
+       string = (*jenv)->NewStringUTF (jenv, gda_numeric_get_string ((GdaNumeric*) num));
        if ((*jenv)->ExceptionCheck (jenv))
                return NULL;
 
diff --git a/providers/jdbc/Makefile.am b/providers/jdbc/Makefile.am
index f4498f2..4883120 100644
--- a/providers/jdbc/Makefile.am
+++ b/providers/jdbc/Makefile.am
@@ -29,8 +29,10 @@ jni_sources = \
 jni_headers = $(jni_sources:.c=.h) 
 jni_classes = $(jni_sources:.c=.class) 
 
-$(jni_sources): $(jni_headers)
-path_jni_sources = $(addprefix $(srcdir)/,$(jni_sources))
+$(libgda_jdbc_la_OBJECTS): $(jni_headers)
+
+aaa:
+       echo $(path_jni_sources)
 
 libgda_jdbc_la_SOURCES = \
        gda-jdbc-blob-op.c \
@@ -52,7 +54,7 @@ libgda_jdbc_la_SOURCES = \
        jni-globals.h \
        jni-wrapper.h \
        jni-wrapper.c \
-       $(path_jni_sources) \
+       $(jni_sources) \
        $(jni_headers)
 
 
@@ -71,7 +73,7 @@ endif
 
 
 $(jni_headers): $(jdbcprov_classes)
-       $(JAVAH) -classpath . -force `basename $@ | sed -e 's/\.h$$//'`
+       $(JAVAH) -classpath . -d $(builddir) -force `basename $@ | sed -e 's/\.h$$//'`
 
 jdbcprov_jar = gdaprovider-5.0.jar
 jdbcprov_sources = \
diff --git a/providers/jdbc/gda-jdbc-provider.c b/providers/jdbc/gda-jdbc-provider.c
index f4da3fb..dcbfabe 100644
--- a/providers/jdbc/gda-jdbc-provider.c
+++ b/providers/jdbc/gda-jdbc-provider.c
@@ -1156,7 +1156,7 @@ gda_jdbc_provider_statement_prepare (GdaServerProvider *provider, GdaConnection
                
                GValue *jexec_res;
                jexec_res = jni_wrapper_method_call (jenv, GdaJPStmt__declareParamTypes,
-                                                    pstmt_obj, NULL, NULL, error, 
(jlong)GPOINTER_TO_INT(cnc), jtypes);
+                                                    pstmt_obj, NULL, NULL, error, (jlong) cnc, jtypes);
                (*jenv)->DeleteLocalRef (jenv, jtypes);
                g_free (ctypes);
                
diff --git a/providers/jdbc/gda-jdbc-recordset.c b/providers/jdbc/gda-jdbc-recordset.c
index 8ac3ae2..12e7722 100644
--- a/providers/jdbc/gda-jdbc-recordset.c
+++ b/providers/jdbc/gda-jdbc-recordset.c
@@ -370,7 +370,7 @@ gda_jdbc_recordset_new (GdaConnection *cnc, GdaJdbcPStmt *ps, GdaSet *exec_param
        }
        
        jexec_res = jni_wrapper_method_call (jenv, GdaJResultSet__declareColumnTypes,
-                                            rs_value, &error_code, &sql_state, &error, 
(jlong)GPOINTER_TO_INT(cnc), jtypes);
+                                            rs_value, &error_code, &sql_state, &error, (jlong) cnc, jtypes);
        (*jenv)->DeleteLocalRef (jenv, jtypes);
        g_free (ctypes);
        
@@ -415,7 +415,7 @@ fetch_next_jdbc_row (GdaJdbcRecordset *model, JNIEnv *jenv, gboolean do_store, G
 
        jexec_res = jni_wrapper_method_call (jenv, GdaJResultSet__fillNextRow,
                                             model->priv->rs_value, &error_code, &sql_state, &lerror,
-                                            (jlong)GPOINTER_TO_INT(prow));
+                                            (jlong) prow);
        if (!jexec_res) {
                if (error && lerror)
                        *error = g_error_copy (lerror);
diff --git a/providers/jdbc/jni-wrapper.c b/providers/jdbc/jni-wrapper.c
index 9426dce..1230e1b 100644
--- a/providers/jdbc/jni-wrapper.c
+++ b/providers/jdbc/jni-wrapper.c
@@ -529,6 +529,8 @@ jni_wrapper_method_call (JNIEnv *jenv, JniWrapperMethod *method, GValue *object,
 
                                (*jenv)-> DeleteLocalRef (jenv, string);
                        }
+                       else
+                               gda_value_set_null (retval);
                }
                else {
                        JavaVM *jvm;
@@ -752,6 +754,8 @@ jni_wrapper_field_get (JNIEnv *jenv, JniWrapperField *field, GValue *object, GEr
 
                                (*jenv)-> DeleteLocalRef (jenv, string);
                        }
+                       else
+                               gda_value_set_null (retval);
                }
                else {
                        JavaVM *jvm;
@@ -902,7 +906,7 @@ jni_wrapper_field_set (JNIEnv *jenv, JniWrapperField *field,
                                        (*jenv)->SetObjectField (jenv, jobj, field->fid, string);
                                (*jenv)-> DeleteLocalRef (jenv, string);
                        }
-                       else if (G_VALUE_TYPE (value) == 0) {
+                       else if (G_VALUE_TYPE (value) == GDA_TYPE_NULL) {
                                if (field->is_static)
                                        (*jenv)->SetStaticObjectField (jenv, field->klass, field->fid, NULL);
                                else
diff --git a/providers/jdbc/libmain.c b/providers/jdbc/libmain.c
index b944c07..d73be8c 100644
--- a/providers/jdbc/libmain.c
+++ b/providers/jdbc/libmain.c
@@ -555,8 +555,29 @@ get_database_name_from_driver_name (const gchar *driver_name)
        } Corresp;
        
        static Corresp carray[] = {
+               {"COM.cloudscape.core.JDBCDriver", "Cloudscape"},
+               {"RmiJdbc.RJDriver", "Cloudscape"},
+               {"COM.ibm.db2.jdbc.app.DB2Driver", "DB2"},
+               {"org.firebirdsql.jdbc.FBDriver", "Firebird"},
+               {"hSql.hDriver", "Hypersonic SQL"},
+               {"org.hsql.jdbcDriver", "Hypersonic SQL"},
+               {"com.informix.jdbc.IfxDriver", "Informix"},
+               {"jdbc.idbDriver", "InstantDB"},
+               {"org.enhydra.instantdb.jdbc.idbDriver", "InstantDB"},
+               {"interbase.interclient.Driver", "Interbase"},
+               {"ids.sql.IDSDriver", "IDS Server"},
+               {"com.mysql.jdbc.Driver", "MySQL"},
+               {"org.gjt.mm.mysql.Driver", "MySQL"},
+               {"oracle.jdbc.driver.OracleDriver", "Oracle"},
+               {"com.pointbase.jdbc.jdbcUniversalDriver", "PointBase"},
                {"org.postgresql.Driver", "PostgreSQL"},
-               {"com.mysql.jdbc.Driver", "MySQL"}
+               {"postgresql.Driver", "v6.5 and earlier"},
+               {"com.microsoft.sqlserver.jdbc.SQLServerDriver", "SqlServer"},
+               {"weblogic.jdbc.mssqlserver4.Driver", "SqlServer"},
+               {"com.ashna.jturbo.driver.Driver", "SqlServer"},
+               {"com.inet.tds.TdsDriver", "SqlServer"},
+               {"com.sybase.jdbc.SybDriver", "Sybase"},
+               {"com.sybase.jdbc2.jdbc.SybDriver", "Sybase"}
        };
 
        gsize i;
diff --git a/providers/jdbc/provider.java b/providers/jdbc/provider.java
index 94e41ed..dc4a121 100644
--- a/providers/jdbc/provider.java
+++ b/providers/jdbc/provider.java
@@ -46,6 +46,8 @@ class GdaJProvider {
                                res = driver.getClass().getName();
                        else
                                res = res + ":" + driver.getClass().getName();
+                       if (false)
+                               System.out.println ("FOUND DRIVER " + driver.getClass().getName());
 
                        // Properties list, for DSN spec creation.
                        if (false) {
@@ -608,7 +610,7 @@ abstract class GdaJValue {
                case java.sql.Types.ARRAY:
                        return "GdaBinary";
                case java.sql.Types.BIGINT:
-                       return "int64";
+                       return "gint64";
                case java.sql.Types.BINARY:
                        return "GdaBinary";
                case java.sql.Types.BIT:
@@ -629,11 +631,12 @@ abstract class GdaJValue {
                case java.sql.Types.DISTINCT:
                        return "GdaBinary";
                case java.sql.Types.DOUBLE:
-                       return "double";
+                       return "gdouble";
                case java.sql.Types.FLOAT:
-                       return "float";
+               case java.sql.Types.REAL:
+                       return "gfloat";
                case java.sql.Types.INTEGER:
-                       return "int";
+                       return "gint";
                case java.sql.Types.JAVA_OBJECT:
                case java.sql.Types.LONGVARBINARY:
                        return "GdaBinary";
@@ -645,12 +648,10 @@ abstract class GdaJValue {
                        return "GdaNumeric";
                case java.sql.Types.OTHER:
                        return "GdaBinary";
-               case java.sql.Types.REAL:
-                       return "float";
                case java.sql.Types.REF:
                        return "GdaBinary";
                case java.sql.Types.SMALLINT:
-                       return "GdaStort";
+                       return "GdaShort";
                case java.sql.Types.STRUCT:
                        return "GdaBinary";
                case java.sql.Types.TIME:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]