db-ddlutils-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r379949 - /db/ddlutils/trunk/src/java/org/apache/ddlutils/task/DumpMetadataTask.java
Date Wed, 22 Feb 2006 22:40:33 GMT
Author: tomdz
Date: Wed Feb 22 14:40:32 2006
New Revision: 379949

URL: http://svn.apache.org/viewcvs?rev=379949&view=rev
Log:
Made dump task more robust against non-conforming JDBC drivers that return null for non-string
columns in the metadata

Modified:
    db/ddlutils/trunk/src/java/org/apache/ddlutils/task/DumpMetadataTask.java

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/task/DumpMetadataTask.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/task/DumpMetadataTask.java?rev=379949&r1=379948&r2=379949&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/task/DumpMetadataTask.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/task/DumpMetadataTask.java Wed Feb 22 14:40:32
2006
@@ -1218,7 +1218,29 @@
 
         if (columns.contains(columnName))
         {
-            value = String.valueOf(result.getInt(columnName));
+        	try
+        	{
+                value = String.valueOf(result.getInt(columnName));
+        	}
+        	catch (SQLException ex)
+        	{
+        		// A few databases do not comply with the jdbc spec and return a string (or null),
+        		// so lets try this just in case
+        		value = result.getString(columnName);
+
+        		if (value != null)
+        		{
+	        		try
+	        		{
+	        			Integer.parseInt(value);
+	        		}
+	        		catch (NumberFormatException parseEx)
+	        		{
+	        			// its no int returned as a string, so lets re-throw the original exception
+	        			throw ex;
+	        		}
+        		}
+        	}
             element.addAttribute(attrName, value);
         }
         return value;
@@ -1240,7 +1262,29 @@
 
         if (columns.contains(columnName))
         {
-            value = String.valueOf(result.getShort(columnName));
+        	try
+        	{
+                value = String.valueOf(result.getShort(columnName));
+        	}
+        	catch (SQLException ex)
+        	{
+        		// A few databases do not comply with the jdbc spec and return a string (or null),
+        		// so lets try strings this just in case
+        		value = result.getString(columnName);
+
+        		if (value != null)
+        		{
+	        		try
+	        		{
+	        			Short.parseShort(value);
+	        		}
+	        		catch (NumberFormatException parseEx)
+	        		{
+	        			// its no short returned as a string, so lets re-throw the original exception
+	        			throw ex;
+	        		}
+        		}
+        	}
             element.addAttribute(attrName, value);
         }
         return value;



Mime
View raw message