You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by dj...@apache.org on 2005/07/06 18:21:47 UTC
svn commit: r209473 - in /incubator/derby/code/trunk/java:
client/org/apache/derby/jdbc/ engine/org/apache/derby/jdbc/
Author: djd
Date: Wed Jul 6 09:21:43 2005
New Revision: 209473
URL: http://svn.apache.org/viewcvs?rev=209473&view=rev
Log:
DERBY-441 - Progress on clean up of published javadoc.
- Remove some unused methods in client data sources.
- Add warnigns for connectionAttributes
- remove attributesAsPassword property for EmebeddedSimpleDataSource
Modified:
incubator/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java
incubator/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientConnectionPoolDataSource.java
incubator/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDataSource.java
incubator/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientXADataSource.java
incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedDataSource.java
incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedSimpleDataSource.java
Modified: incubator/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java?rev=209473&r1=209472&r2=209473&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java (original)
+++ incubator/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java Wed Jul 6 09:21:43 2005
@@ -60,7 +60,7 @@
//---------------------contructors/finalizers---------------------------------
// This class is abstract, hide the default constructor
- protected ClientBaseDataSource() {
+ ClientBaseDataSource() {
}
// ---------------------------- loginTimeout -----------------------------------
@@ -91,7 +91,7 @@
*
* @see #traceLevel
*/
- protected transient PrintWriter logWriter = null;
+ private transient PrintWriter logWriter;
public synchronized void setLogWriter(PrintWriter logWriter) {
this.logWriter = logWriter;
@@ -108,7 +108,7 @@
// and therefore may throw an SQLException.
//
//
- protected String databaseName = null;
+ protected String databaseName;
public final static String propertyKey_databaseName = "databaseName";
// databaseName is not permitted in a properties object
@@ -116,7 +116,7 @@
// ---------------------------- description ------------------------------
// A description of this data source.
- protected String description = null;
+ protected String description;
public final static String propertyKey_description = "description";
// ---------------------------- dataSourceName -----------------------------------
@@ -125,7 +125,7 @@
// used to name an underlying XADataSource,
// or ConnectionPoolDataSource when pooling of connections is done.
//
- protected String dataSourceName = null;
+ protected String dataSourceName;
public final static String propertyKey_dataSourceName = "dataSourceName";
// ---------------------------- portNumber -----------------------------------
@@ -165,10 +165,6 @@
public final static int HOLD_CURSORS_OVER_COMMIT = 1; // this matches jdbc 3 ResultSet.HOLD_CURSORS_OVER_COMMIT
public final static int CLOSE_CURSORS_AT_COMMIT = 2; // this matches jdbc 3 ResultSet.CLOSE_CURSORS_AT_COMMIT
- public final static int NOT_SET = 0; // 0 means not set.
- public final static int YES = 1; // ="yes" as property string
- public final static int NO = 2; // ="no" as property string
-
// ---------------------------- securityMechanism -----------------------------------
//
@@ -238,7 +234,7 @@
// ---------------------------- traceFile -----------------------------------
//
- protected String traceFile = null;
+ protected String traceFile;
public final static String propertyKey_traceFile = "traceFile";
public static String getTraceFile(Properties properties) {
@@ -249,7 +245,7 @@
// For the suffix of the trace file when traceDirectory is enabled.
private transient int traceFileSuffixIndex_ = 0;
//
- protected String traceDirectory = null;
+ protected String traceDirectory;
public final static String propertyKey_traceDirectory = "traceDirectory";
public static String getTraceDirectory(Properties properties) {
@@ -278,11 +274,15 @@
return properties.getProperty("password");
}
- protected String password = null;
+ protected String password;
- synchronized public void setPassword(String password) {
+ synchronized public final void setPassword(String password) {
this.password = password;
}
+
+ public final String getPassword() {
+ return password;
+ }
//------------------------ interface methods ---------------------------------
@@ -358,6 +358,7 @@
* Not an external. Do not document in pubs. Populates member data for this data source given a JNDI reference.
*/
public void hydrateFromReference(Reference ref) throws SQLException {
+
RefAddr address;
Class clz = getClass();
@@ -495,14 +496,14 @@
// If neither traceFile nor jdbc logWriter are set, then null is returned.
// logWriterInUseSuffix used only for trace directories to indicate whether
// log writer is use is from xads, cpds, sds, ds, driver, config, reset.
- public LogWriter computeDncLogWriterForNewConnection(String logWriterInUseSuffix) throws SqlException {
+ LogWriter computeDncLogWriterForNewConnection(String logWriterInUseSuffix) throws SqlException {
return computeDncLogWriterForNewConnection(logWriter, traceDirectory, traceFile, traceFileAppend, traceLevel, logWriterInUseSuffix, traceFileSuffixIndex_++);
}
// Called on for connection requests.
// The java.io.PrintWriter overrides the traceFile setting.
// If neither traceFile, nor logWriter, nor traceDirectory are set, then null is returned.
- static public LogWriter computeDncLogWriterForNewConnection(PrintWriter logWriter, String traceDirectory, String traceFile, boolean traceFileAppend, int traceLevel, String logWriterInUseSuffix, int traceFileSuffixIndex) throws SqlException {
+ static LogWriter computeDncLogWriterForNewConnection(PrintWriter logWriter, String traceDirectory, String traceFile, boolean traceFileAppend, int traceLevel, String logWriterInUseSuffix, int traceFileSuffixIndex) throws SqlException {
int globaltraceFileSuffixIndex = Configuration.traceFileSuffixIndex__++;
// compute regular dnc log writer if there is any
@@ -618,7 +619,7 @@
// tokenize "property=value;property=value..." and returns new properties object
//This method is used both by ClientDriver to parse the url and
// ClientDataSource.setConnectionAttributes
- public static Properties tokenizeAttributes(String attributeString, Properties properties) throws SqlException {
+ static Properties tokenizeAttributes(String attributeString, Properties properties) throws SqlException {
Properties augmentedProperties;
if (attributeString == null) {
@@ -783,6 +784,11 @@
/**
* Set this property to pass in more Derby specific connection URL attributes.
+ * <BR>
+ * Any attributes that can be set using a property of this DataSource implementation
+ * (e.g user, password) should not be set in connectionAttributes. Conflicting
+ * settings in connectionAttributes and properties of the DataSource will lead to
+ * unexpected behaviour.
*
* @param prop set to the list of Cloudscape connection attributes separated by semi-colons. E.g., to specify an
* encryption bootPassword of "x8hhk2adf", and set upgrade to true, do the following: <PRE>
@@ -871,7 +877,7 @@
* The dataSource keeps individual fields for the values that are relevant to the client. These need to be updated
* when set connection attributes is called.
*/
- protected void updateDataSourceValues(Properties prop) {
+ void updateDataSourceValues(Properties prop) {
if (prop.containsKey(propertyKey_user)) {
setUser(getUser(prop));
}
Modified: incubator/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientConnectionPoolDataSource.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientConnectionPoolDataSource.java?rev=209473&r1=209472&r2=209473&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientConnectionPoolDataSource.java (original)
+++ incubator/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientConnectionPoolDataSource.java Wed Jul 6 09:21:43 2005
@@ -47,7 +47,7 @@
if (dncLogWriter != null) {
dncLogWriter.traceEntry(this, "getPooledConnection");
}
- PooledConnection pooledConnection = getPooledConnectionX(dncLogWriter, this, user, password);
+ PooledConnection pooledConnection = getPooledConnectionX(dncLogWriter, this, getUser(), getPassword());
if (dncLogWriter != null) {
dncLogWriter.traceExit(this, "getPooledConnection", pooledConnection);
}
@@ -61,19 +61,6 @@
dncLogWriter.traceEntry(this, "getPooledConnection", user, "<escaped>");
}
PooledConnection pooledConnection = getPooledConnectionX(dncLogWriter, this, user, password);
- if (dncLogWriter != null) {
- dncLogWriter.traceExit(this, "getPooledConnection", pooledConnection);
- }
- return pooledConnection;
- }
-
- // method that establishes the initial physical connection using DS properties instead of CPDS properties.
- public PooledConnection getPooledConnection(ClientDataSource ds, String user, String password) throws SQLException {
- LogWriter dncLogWriter = ds.computeDncLogWriterForNewConnection("_cpds");
- if (dncLogWriter != null) {
- dncLogWriter.traceEntry(this, "getPooledConnection", ds, user, "<escaped>");
- }
- PooledConnection pooledConnection = getPooledConnectionX(dncLogWriter, ds, user, password);
if (dncLogWriter != null) {
dncLogWriter.traceExit(this, "getPooledConnection", pooledConnection);
}
Modified: incubator/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDataSource.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDataSource.java?rev=209473&r1=209472&r2=209473&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDataSource.java (original)
+++ incubator/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDataSource.java Wed Jul 6 09:21:43 2005
@@ -132,7 +132,7 @@
* @throws java.sql.SQLException if a database-access error occurs.
*/
public Connection getConnection() throws SQLException {
- return getConnection(user, password);
+ return getConnection(getUser(), getPassword());
}
/**
@@ -152,7 +152,7 @@
// This log writer will be passed to the agent constructor.
LogWriter dncLogWriter = super.computeDncLogWriterForNewConnection("_sds");
- updateDataSourceValues(tokenizeAttributes(connectionAttributes, null));
+ updateDataSourceValues(tokenizeAttributes(getConnectionAttributes(), null));
return new NetConnection((NetLogWriter) dncLogWriter, user, password, this, -1, false);
}
Modified: incubator/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientXADataSource.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientXADataSource.java?rev=209473&r1=209472&r2=209473&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientXADataSource.java (original)
+++ incubator/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientXADataSource.java Wed Jul 6 09:21:43 2005
@@ -39,7 +39,7 @@
}
public XAConnection getXAConnection() throws SQLException {
- return getXAConnection(user, password);
+ return getXAConnection(getUser(), getPassword());
}
public XAConnection getXAConnection(String user, String password) throws SQLException {
Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedDataSource.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedDataSource.java?rev=209473&r1=209472&r2=209473&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedDataSource.java (original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedDataSource.java Wed Jul 6 09:21:43 2005
@@ -109,6 +109,11 @@
E.g. <code>setConnectionAttributes("bootPassword=erd3234dggd3kazkj3000");</code>.
<BR>The database name must be set by the DataSource property <code>databaseName</code> and not by setting the <code>databaseName</code>
connection attribute in the <code>connectionAttributes</code> property.
+ <BR>
+ Any attributes that can be set using a property of this DataSource implementation
+ (e.g user, password) should not be set in connectionAttributes. Conflicting
+ settings in connectionAttributes and properties of the DataSource will lead to
+ unexpected behaviour.
<BR>Please see the Derby documentation for a complete list of connection attributes. </LI>
<LI><B><code>createDatabase</code></B> (String): <I>Optional</I>
@@ -240,7 +245,7 @@
// Unlike a DataSource, LocalDriver is shared by all
// Derby databases in the same jvm.
- transient protected InternalDriver driver;
+ transient InternalDriver driver;
transient private String jdbcurl;
@@ -358,6 +363,11 @@
/**
Set this property to pass in more Derby specific
connection URL attributes.
+ <BR>
+ Any attributes that can be set using a property of this DataSource implementation
+ (e.g user, password) should not be set in connectionAttributes. Conflicting
+ settings in connectionAttributes and properties of the DataSource will lead to
+ unexpected behaviour.
@param prop set to the list of Derby connection
attributes separated by semi-colons. E.g., to specify an encryption
Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedSimpleDataSource.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedSimpleDataSource.java?rev=209473&r1=209472&r2=209473&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedSimpleDataSource.java (original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedSimpleDataSource.java Wed Jul 6 09:21:43 2005
@@ -104,11 +104,6 @@
*/
private String connectionAttributes;
- /**
- * Set password to be a set of connection attributes.
- */
- private boolean attributesAsPassword;
-
/** instance variables that will not be serialized */
transient private PrintWriter printer;
@@ -116,7 +111,7 @@
// Unlike a DataSource, LocalDriver is shared by all
// Cloudscape databases in the same jvm.
- transient protected InternalDriver driver;
+ transient private InternalDriver driver;
transient private String jdbcurl;
@@ -333,7 +328,12 @@
/**
* Set this property to pass in more Cloudscape specific connection URL
* attributes.
- *
+ <BR>
+ Any attributes that can be set using a property of this DataSource implementation
+ (e.g user, password) should not be set in connectionAttributes. Conflicting
+ settings in connectionAttributes and properties of the DataSource will lead to
+ unexpected behaviour.
+ *
* @param prop
* set to the list of Cloudscape connection attributes separated
* by semi-colons. E.g., to specify an encryption bootPassword of
@@ -357,30 +357,6 @@
return connectionAttributes;
}
- /**
- * Set attributeAsPassword property to enable passing connection request
- * attributes in the password argument of getConnection. If the property is
- * set to true then the password argument of the
- * DataSource.getConnection(String user, String password) method call is
- * taken to be a list of connection attributes with the same format as the
- * connectionAttributes property.
- *
- * @param attributesAsPassword
- * true to encode password argument as a set of connection
- * attributes in a connection request.
- */
- public final void setAttributesAsPassword(boolean attributesAsPassword) {
- this.attributesAsPassword = attributesAsPassword;
- update();
- }
-
- /**
- * Return the value of the attributesAsPassword property.
- */
- public final boolean getAttributesAsPassword() {
- return attributesAsPassword;
- }
-
/*
* DataSource methods
*/
@@ -393,7 +369,7 @@
* if a database-access error occurs.
*/
public final Connection getConnection() throws SQLException {
- return this.getConnection(getUser(), getPassword(), false);
+ return this.getConnection(getUser(), getPassword());
}
/**
@@ -413,45 +389,20 @@
*/
public final Connection getConnection(String username, String password)
throws SQLException {
- return this.getConnection(username, password, true);
- }
-
- /**
- * @param requestPassword
- * true if the password came from the getConnection() call.
- */
- final Connection getConnection(String username, String password,
- boolean requestPassword) throws SQLException {
Properties info = new Properties();
if (username != null)
info.put(Attribute.USERNAME_ATTR, username);
- if (!requestPassword || !attributesAsPassword) {
- if (password != null)
- info.put(Attribute.PASSWORD_ATTR, password);
- }
+ if (password != null)
+ info.put(Attribute.PASSWORD_ATTR, password);
if (createDatabase != null)
info.put(Attribute.CREATE_ATTR, "true");
if (shutdownDatabase != null)
info.put(Attribute.SHUTDOWN_ATTR, "true");
- String url = jdbcurl;
-
- if (attributesAsPassword && requestPassword && password != null) {
-
- StringBuffer sb = new StringBuffer(url.length() + password.length()
- + 1);
-
- sb.append(url);
- sb.append(';');
- sb.append(password); // these are now request attributes on the URL
-
- url = sb.toString();
-
- }
- Connection conn = findDriver().connect(url, info);
+ Connection conn = findDriver().connect(jdbcurl, info);
// JDBC driver's getConnection method returns null if
// the driver does not handle the request's URL.