Author: weaver
Date: Mon Sep 24 06:02:12 2007
New Revision: 578797
URL: http://svn.apache.org/viewvc?rev=578797&view=rev
Log:
Fix for JS2-593, NullPointerExceptions caused by not checking for a
pre-existing, JNDI datasource.
Modified:
portals/jetspeed-2/trunk/components/jetspeed-rdbms/src/main/java/org/apache/jetspeed/components/rdbms/ojb/ConnectionRepositoryEntry.java
Modified:
portals/jetspeed-2/trunk/components/jetspeed-rdbms/src/main/java/org/apache/jetspeed/components/rdbms/ojb/ConnectionRepositoryEntry.java
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/jetspeed-rdbms/src/main/java/org/apache/jetspeed/components/rdbms/ojb/ConnectionRepositoryEntry.java?rev=578797&r1=578796&r2=578797&view=diff
==============================================================================
---
portals/jetspeed-2/trunk/components/jetspeed-rdbms/src/main/java/org/apache/jetspeed/components/rdbms/ojb/ConnectionRepositoryEntry.java
(original)
+++
portals/jetspeed-2/trunk/components/jetspeed-rdbms/src/main/java/org/apache/jetspeed/components/rdbms/ojb/ConnectionRepositoryEntry.java
Mon Sep 24 06:02:12 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,29 @@
public void setLogWriter(PrintWriter out) throws SQLException {
}
}
+
+ public Connection getConnection() throws SQLException {
+ if(externalDs != null)
+ {
+ return externalDs.getConnection();
+ }
+ else
+ {
+ return super.getConnection();
+ }
+ }
+
+ 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]