ASF Bugzilla – Attachment 16563 Details for
Bug 33452
sql's getConnection doesn't allow for aribtrary property setting
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch to fix the bug
ConnectionPropertyPatch.txt (text/plain), 3.94 KB, created by
Magnus Grimsell
on 2005-09-30 16:26:16 UTC
(
hide
)
Description:
Patch to fix the bug
Filename:
MIME Type:
Creator:
Magnus Grimsell
Created:
2005-09-30 16:26:16 UTC
Size:
3.94 KB
patch
obsolete
>Index: C:/eclipse-workspace-os/ant/src/main/org/apache/tools/ant/taskdefs/JDBCTask.java >=================================================================== >--- C:/eclipse-workspace-os/ant/src/main/org/apache/tools/ant/taskdefs/JDBCTask.java (revision 292654) >+++ C:/eclipse-workspace-os/ant/src/main/org/apache/tools/ant/taskdefs/JDBCTask.java (working copy) >@@ -21,8 +21,12 @@ > import java.sql.DatabaseMetaData; > import java.sql.Driver; > import java.sql.SQLException; >+import java.util.ArrayList; > import java.util.Hashtable; >+import java.util.Iterator; >+import java.util.List; > import java.util.Properties; >+ > import org.apache.tools.ant.AntClassLoader; > import org.apache.tools.ant.BuildException; > import org.apache.tools.ant.Project; >@@ -138,6 +142,11 @@ > * RDBMS Version needed for this SQL. > **/ > private String version = null; >+ >+ /** >+ * Connection properties for this SQL >+ */ >+ private ConnectionProperties connectionProperties = null; > > /** > * Sets the classpath for loading the driver. >@@ -229,6 +238,15 @@ > } > > /** >+ * Sets the connection properties for this SQL. >+ * @param props connection properties >+ */ >+ public void addConnectionproperties(ConnectionProperties props) >+ { >+ connectionProperties = props; >+ } >+ >+ /** > * Verify we are connected to the correct RDBMS > * @param conn the jdbc connection > * @return true if we are connected to the correct RDBMS >@@ -314,6 +332,17 @@ > Properties info = new Properties(); > info.put("user", getUserId()); > info.put("password", getPassword()); >+ if(connectionProperties != null) >+ { >+ Iterator iter = connectionProperties.iterator(); >+ while(iter.hasNext()) >+ { >+ ConnectionProperty p = (ConnectionProperty)iter.next(); >+ log("Setting property " + p.getName() + " to " + p.getValue(), >+ Project.MSG_VERBOSE); >+ info.put(p.getName(), p.getValue()); >+ } >+ } > Connection conn = getDriver().connect(getUrl(), info); > > if (conn == null) { >@@ -464,4 +493,77 @@ > return version; > } > >+ /** >+ * Connection properties for a JDBC connection >+ */ >+ public static class ConnectionProperties >+ { >+ /** >+ * List of ConnectionProperty objects >+ */ >+ private List mProperties = new ArrayList(); >+ >+ /** >+ * Add a connection property >+ * @param p the connection property to add >+ */ >+ public void addProperty(ConnectionProperty p) >+ { >+ mProperties.add(p); >+ } >+ >+ /** >+ * Returns an iterator with ConnectionProperty objects >+ * @return iterator with ConnectionProperty objects >+ */ >+ public Iterator iterator() >+ { >+ return mProperties.iterator(); >+ } >+ } >+ >+ /** >+ * Connection property for a JDBC connection >+ */ >+ public static class ConnectionProperty >+ { >+ /** >+ * Name of the property >+ */ >+ private String name; >+ >+ /** >+ * Value of the property >+ */ >+ private String value; >+ >+ /** >+ * @return Returns the name. >+ */ >+ public String getName() >+ { >+ return name; >+ } >+ /** >+ * @param name The name to set. >+ */ >+ public void setName(String name) >+ { >+ this.name = name; >+ } >+ /** >+ * @return Returns the value. >+ */ >+ public String getValue() >+ { >+ return value; >+ } >+ /** >+ * @param value The value to set. >+ */ >+ public void setValue(String value) >+ { >+ this.value = value; >+ } >+ } > } >\ No newline at end of file
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 33452
: 16563