You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by rw...@apache.org on 2003/03/06 16:22:26 UTC
cvs commit: jakarta-commons/dbcp/src/java/org/apache/commons/dbcp BasicDataSourceFactory.java
rwaldhoff 2003/03/06 07:22:26
Modified: dbcp/src/java/org/apache/commons/dbcp
BasicDataSourceFactory.java
Log:
Expose a connectionProperties property.
This closes bug 13930 <http://issues.apache.org/bugzilla/show_bug.cgi?id=13930>
Thanks Peter.
Revision Changes Path
1.5 +34 -6 jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/BasicDataSourceFactory.java
Index: BasicDataSourceFactory.java
===================================================================
RCS file: /home/cvs/jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/BasicDataSourceFactory.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- BasicDataSourceFactory.java 6 Mar 2003 14:58:42 -0000 1.4
+++ BasicDataSourceFactory.java 6 Mar 2003 15:22:25 -0000 1.5
@@ -61,12 +61,15 @@
package org.apache.commons.dbcp;
+import java.io.ByteArrayInputStream;
+import java.util.Enumeration;
import java.util.Hashtable;
+import java.util.Properties;
+
import javax.naming.Context;
import javax.naming.Name;
-import javax.naming.NamingException;
-import javax.naming.Reference;
import javax.naming.RefAddr;
+import javax.naming.Reference;
import javax.naming.spi.ObjectFactory;
@@ -230,9 +233,34 @@
(Boolean.valueOf(ra.getContent().toString()).booleanValue());
}
+ ra = ref.get("connectionProperties");
+ if (ra != null) {
+ Properties p = getProperties(ra.getContent().toString());
+ Enumeration e = p.propertyNames();
+ while (e.hasMoreElements()) {
+ String propertyName = (String) e.nextElement();
+ dataSource.addConnectionProperty(propertyName, p.getProperty(propertyName));
+ }
+ }
+
// Return the configured data source instance
return (dataSource);
+ }
+
+
+ /**
+ * <p>Parse properties from the string. Format of the string must be [propertyName=property;]*<p>
+ * @param propText
+ * @return Properties
+ * @throws Exception
+ */
+ static private Properties getProperties(String propText) throws Exception {
+ Properties p = new Properties();
+ if (propText != null) {
+ p.load(new ByteArrayInputStream(propText.replace(';', '\n').getBytes()));
+ }
+ return p;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org