openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ppod...@apache.org
Subject svn commit: r675952 - in /openjpa/trunk: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/ openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/schema/ openjpa-kernel/src/main/java/org/apache/openjpa/util/
Date Fri, 11 Jul 2008 13:48:50 GMT
Author: ppoddar
Date: Fri Jul 11 06:48:50 2008
New Revision: 675952

URL: http://svn.apache.org/viewvc?rev=675952&view=rev
Log:
OPENJPA-656 : raise informational error on initial connection failure

Modified:
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DataSourceFactory.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/SimpleDriverDataSource.java
    openjpa/trunk/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/schema/localizer.properties
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/StoreException.java

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DataSourceFactory.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DataSourceFactory.java?rev=675952&r1=675951&r2=675952&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DataSourceFactory.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DataSourceFactory.java
Fri Jul 11 06:48:50 2008
@@ -237,7 +237,14 @@
 
             return ds;
         } catch (Exception e) {
-            throw new StoreException(e).setFatal(true);
+        	throw new StoreException(_loc.get("conn-failed", factory2 
+        	  ? new Object[]{conf.getConnection2DriverName(), 
+        			         conf.getConnection2URL(), 
+        			         conf.getConnection2Properties()}
+        	  : new Object[]{conf.getConnectionDriverName(),
+        		             conf.getConnectionURL(), 
+        		             conf.getConnectionProperties()}),
+        		             e);
         } finally {
             if (conn != null)
                 try {

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/SimpleDriverDataSource.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/SimpleDriverDataSource.java?rev=675952&r1=675951&r2=675952&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/SimpleDriverDataSource.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/SimpleDriverDataSource.java
Fri Jul 11 06:48:50 2008
@@ -30,7 +30,9 @@
 
 import org.apache.openjpa.jdbc.sql.DBDictionary;
 import org.apache.openjpa.lib.util.J2DoPrivHelper;
+import org.apache.openjpa.lib.util.Localizer;
 import org.apache.openjpa.util.StoreException;
+import org.apache.openjpa.util.UserException;
 
 /**
  * Non-pooling driver data source.
@@ -46,6 +48,9 @@
     private Properties _connectionFactoryProperties;
     private Driver _driver;
     private ClassLoader _classLoader;
+    
+    protected static Localizer _loc = 
+    	Localizer.forPackage(SimpleDriverDataSource.class);
 
     public Connection getConnection()
         throws SQLException {
@@ -70,7 +75,12 @@
 
     public Connection getConnection(Properties props)
         throws SQLException {
-        return getDriver().connect(_connectionURL, props);
+    	Connection con = getDriver().connect(_connectionURL, props);
+    	if (con == null) {
+        	throw new UserException(_loc.get("conn-failed",
+        			_connectionDriverName, _connectionURL, props));
+        }
+        return con;
     }
 
     public int getLoginTimeout() {

Modified: openjpa/trunk/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/schema/localizer.properties
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/schema/localizer.properties?rev=675952&r1=675951&r2=675952&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/schema/localizer.properties
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/schema/localizer.properties
Fri Jul 11 06:48:50 2008
@@ -148,4 +148,6 @@
 delete-table-contents: An error occurred while attempting to delete all \
     records from all mapped tables.
 set-auto-commit: DataSource connection setAutoCommit to "{0}"
-
+conn-failed: Failed to connect to DataSource. Verify Driver "{0}", URL "{1}" \
+	and connection properties "{2}" are correct. See the nested exception for \
+	further details.

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/StoreException.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/StoreException.java?rev=675952&r1=675951&r2=675952&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/StoreException.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/StoreException.java
Fri Jul 11 06:48:50 2008
@@ -47,6 +47,14 @@
         super(cause);
     }
 
+    public StoreException(String msg, Throwable cause) {
+        super(msg, cause);
+    }
+
+    public StoreException(Message msg, Throwable cause) {
+        super(msg.getMessage(), cause);
+    }
+    
     public int getType() {
         return STORE;
     }



Mime
View raw message