You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by we...@apache.org on 2007/09/21 16:54:32 UTC

svn commit: r578156 - /portals/jetspeed-2/branches/JETSPEED-2.1.3/components/rdbms/src/java/org/apache/jetspeed/components/rdbms/ojb/ConnectionRepositoryEntry.java

Author: weaver
Date: Fri Sep 21 07:54:31 2007
New Revision: 578156

URL: http://svn.apache.org/viewvc?rev=578156&view=rev
Log:
Fix for JS2-593, NullPointerExceptions caused by not checking for a pre-existing, JNDI datasource.

Modified:
    portals/jetspeed-2/branches/JETSPEED-2.1.3/components/rdbms/src/java/org/apache/jetspeed/components/rdbms/ojb/ConnectionRepositoryEntry.java

Modified: portals/jetspeed-2/branches/JETSPEED-2.1.3/components/rdbms/src/java/org/apache/jetspeed/components/rdbms/ojb/ConnectionRepositoryEntry.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/components/rdbms/src/java/org/apache/jetspeed/components/rdbms/ojb/ConnectionRepositoryEntry.java?rev=578156&r1=578155&r2=578156&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/components/rdbms/src/java/org/apache/jetspeed/components/rdbms/ojb/ConnectionRepositoryEntry.java (original)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/components/rdbms/src/java/org/apache/jetspeed/components/rdbms/ojb/ConnectionRepositoryEntry.java Fri Sep 21 07:54:31 2007
@@ -99,6 +99,8 @@
     private String password = null;
     private boolean jetspeedEngineScoped = true;
 
+	private DataSource externalDs;
+
     public ConnectionRepositoryEntry()
     {
         super();
@@ -283,7 +285,8 @@
             }
             Context initialContext = new InitialContext();
             ds = (DataSource) initialContext.lookup(jndiName);
-            jcd.setDatasourceName(jndiName);
+            externalDs = ds;
+			jcd.setDatasourceName(jndiName);
         } 
         else 
         {
@@ -478,5 +481,31 @@
         public void setLogWriter(PrintWriter out) throws SQLException {
         }
     }
+
+	@Override
+	public Connection getConnection() throws SQLException {
+		if(externalDs != null)
+		{
+			return externalDs.getConnection();
+		}
+		else
+		{
+		   return super.getConnection();
+		}
+	}
+
+	@Override
+	public Connection getConnection(String username, String password)
+			throws SQLException {
+		
+		if(externalDs != null)
+		{
+			return externalDs.getConnection(username, password);
+		}
+		else
+		{
+		   return super.getConnection(username, password);
+		}		
+	}
 
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org