db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r171118 - /incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/util.java /incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/utilMain.java
Date Fri, 20 May 2005 13:50:33 GMT
Author: djd
Date: Fri May 20 06:50:32 2005
New Revision: 171118

URL: http://svn.apache.org/viewcvs?rev=171118&view=rev
Log:
Cleanup ij code that handles the initial connection opened
from properties such as ij.database or ij.dataSource.
ij.database clearly now overrides ij.dataSource rather
than being somewhat tangled. Allows ij to run in J2ME.

Modified:
    incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/util.java
    incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/utilMain.java

Modified: incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/util.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/util.java?rev=171118&r1=171117&r2=171118&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/util.java (original)
+++ incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/util.java Fri May
20 06:50:32 2005
@@ -28,6 +28,7 @@
 import java.io.FileNotFoundException;
 import java.io.InputStream;
 import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
 
 import java.sql.Connection;
 import java.sql.DriverManager;
@@ -408,18 +409,21 @@
 	    if (driver == null) {
 		driver = "org.apache.derby.jdbc.EmbeddedDriver";
 	    }
+	    
+	    loadDriver(driver);
+		con = DriverManager.getConnection(databaseURL,connInfo);
+		return con;  
+	}
 
 	    // handle datasource property
 	    String dsName = System.getProperty("ij.dataSource");
-	    if (dsName == null) {
-		loadDriver(driver);
-		con = DriverManager.getConnection(databaseURL,connInfo);
-		return con;
+	    if (dsName == null)
+	    	return null;
 
-	    } else { // a datasource
 		// Get a new proxied connection through DataSource
 		Object ds = null; // really javax.sql.DataSource
 		try {
+			
 		    Class dc = Class.forName(dsName);
 		    ds = dc.newInstance();
 		    
@@ -427,19 +431,20 @@
 		    setupDataSource(ds);
 
 		    // Java method call "by hand" {  con = ds.getConnection(); }
-		    {
 			java.lang.reflect.Method m = dc.getMethod("getConnection", null); 
-			con = (java.sql.Connection) m.invoke(ds, new Object[] {});
-		    }
-		} catch (Throwable error) {
-		    error.printStackTrace(System.out);
+			return (java.sql.Connection) m.invoke(ds, new Object[] {});
+		} catch (InvocationTargetException ite)
+		{
+			if (ite.getTargetException() instanceof SQLException)
+				throw (SQLException) ite.getTargetException();
+			ite.printStackTrace(System.out);
+		} catch (Exception e)
+		{
+			e.printStackTrace(System.out);
 		}
-		return con;
-	    } // datasource
-	}
-	// failed
-	return null;
-    }
+		
+		return null;
+   }
 
 
 	public static Properties updateConnInfo(String user, String password, Properties connInfo)

Modified: incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/utilMain.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/utilMain.java?rev=171118&r1=171117&r2=171118&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/utilMain.java (original)
+++ incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/utilMain.java Fri
May 20 06:50:32 2005
@@ -354,7 +354,7 @@
 			Driver d = null;
 			try {
 			    d = DriverManager.getDriver("jdbc:derby:");
-			} catch (Exception e) {
+			} catch (Throwable e) {
 				d = null;
 			}
 			if (d!=null) { // do we have a driver running? shutdown on exit.



Mime
View raw message