>The other reason why this is happening, might be that the column in
>question is a LONG column which is known to give problems with Oracle
>JDBC drivers, especially the thin driver.

You seem to be right, Tom.
My tests proved that resultset.getString("COLUMN_DEF") :
+can't be called twice (if .next() is not called obviously)
+always fails for primary fields with 9i- drivers
+fails if called after e.g. .getString("IS_NULLABLE") with 10g drivers
+works OK if called first *with 10g drivers*

So what I did is modify
JdbcModelReader.getColumnsForTable(DatabaseMetaData, String)
and move the call of
getValueAsString(..., "COLUMN_DEF", ...)
to be the first one called. This works perfectly on my platform now.

I have included the corresponding patch. You can of course do whatever you want with it, provided I am responsible for nothing :P Do you think this will have side effects? Can I use DdlUtils that way safely?

HTH & TIA,

Alexandre BORGOLTZ
Head of Technology

SmartJog SA
Phone: +33 (0)1 4996 6324
Fax: +33 (0)1 4996 6405
Mobile: +33 (0)6 8882 1417
[EMAIL PROTECTED]

Index: 
F:/data/buster/commons-sql/src/java/org/apache/ddlutils/io/JdbcModelReader.java
===================================================================
--- 
F:/data/buster/commons-sql/src/java/org/apache/ddlutils/io/JdbcModelReader.java 
    (revision 293570)
+++ 
F:/data/buster/commons-sql/src/java/org/apache/ddlutils/io/JdbcModelReader.java 
    (working copy)
@@ -226,6 +226,32 @@
             {
                 Column col = new Column();
 
+                /**
+                 * Oracle driver COLUMN_DEF/long workaround
+                 * Get the "COLUMN_DEF" value first as it is LONG and 
+                 * oracle drivers don't handle it properly otherwise
+                 * [EMAIL PROTECTED] 2005/10/13
+                 * 
+                 */
+                // sometimes the default comes back with parenthesis around it 
(jTDS/mssql)
+                String columnDefaultValue = getValueAsString(columnData, 
"COLUMN_DEF", availableColumns, null);
+
+                if (columnDefaultValue != null)
+                {
+                    Matcher m = defaultPattern.matcher(columnDefaultValue);
+
+                    if (m.matches())
+                    {
+                        columnDefaultValue = m.group(1);
+                    }
+                    col.setDefaultValue(columnDefaultValue);
+                }
+                /**
+                 * END Oracle driver COLUMN_DEF/long workaround
+                 * [EMAIL PROTECTED] 2005/10/13
+                 * 
+                 */
+                
                 col.setName(getValueAsString(columnData, "COLUMN_NAME", 
availableColumns, "UNKNOWN"));
                 col.setTypeCode(getValueAsInt(columnData, "DATA_TYPE", 
availableColumns, java.sql.Types.OTHER));
                 col.setPrecisionRadix(getValueAsInt(columnData, 
"NUM_PREC_RADIX", availableColumns, 10));
@@ -243,19 +269,7 @@
                     col.setPrimaryKey(false);
                 }
 
-                // sometimes the default comes back with parenthesis around it 
(jTDS/mssql)
-                String columnDefaultValue = getValueAsString(columnData, 
"COLUMN_DEF", availableColumns, null);
-
-                if (columnDefaultValue != null)
-                {
-                    Matcher m = defaultPattern.matcher(columnDefaultValue);
-
-                    if (m.matches())
-                    {
-                        columnDefaultValue = m.group(1);
-                    }
-                    col.setDefaultValue(columnDefaultValue);
-                }
+               
                 columns.add(col);
             }
             return columns;

Reply via email to