Update of /cvsroot/monetdb/clients/src/java/src/nl/cwi/monetdb/jdbc
In directory
sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv26248/src/nl/cwi/monetdb/jdbc
Modified Files:
Tag: Clients_1-20
MonetDataSource.java
Log Message:
Remove weird settings from DataSource implementation, and allow the user to set
an URL instead. Not sure if/how this works, but it seems it is based on
reflection or something.
Index: MonetDataSource.java
===================================================================
RCS file:
/cvsroot/monetdb/clients/src/java/src/nl/cwi/monetdb/jdbc/MonetDataSource.java,v
retrieving revision 1.2.10.1
retrieving revision 1.2.10.2
diff -u -d -r1.2.10.1 -r1.2.10.2
--- MonetDataSource.java 15 Nov 2007 08:49:58 -0000 1.2.10.1
+++ MonetDataSource.java 16 Nov 2007 09:46:00 -0000 1.2.10.2
@@ -38,14 +38,12 @@
* @version 0.1
*/
public class MonetDataSource implements DataSource {
- private String databaseName;
- private String hostName;
- private int portNumber;
private String description;
private int loginTimeout = 0;
private String user;
- // insecure, but no big issue as long as MonetDB itself doesn't do
decent authorisation
+ // insecure, but how to do it better?
private String password;
+ private String url;
// the following properties are also standard:
// private String dataSourceName;
@@ -58,14 +56,12 @@
/**
* Constructor of a MonetDataSource which uses default settings for a
- * connection. You probably want to change these settings using the
- * methods setDatabaseName, setServerName, setPortNumber, etc.
+ * connection. You probably want to change this setting using the
+ * method setURL.
*/
public MonetDataSource() {
- databaseName = "demo";
- hostName = "localhost";
- portNumber = 50000;
description = "MonetDB database";
+ url = "jdbc:monetdb://localhost/";
driver = new MonetDriver();
}
@@ -90,7 +86,9 @@
* @return a MonetConnection
* @throws SQLException if connecting to the database fails
*/
- public Connection getConnection(String username, String password)
throws SQLException {
+ public Connection getConnection(String username, String password)
+ throws SQLException
+ {
if (loginTimeout > 0) {
/// could enable Socket.setSoTimeout(int timeout)
here...
}
@@ -98,10 +96,7 @@
props.put("user", username);
props.put("password", password);
- return(driver.connect(
- "jdbc:monetdb://" + hostName + ":" + portNumber + "/" +
databaseName,
- props
- ));
+ return(driver.connect(url, props));
}
@@ -172,21 +167,21 @@
}
/**
- * Gets the database name
+ * Gets the connection URL
*
- * @return the database name
+ * @return the connection URL
*/
- public String getDatabaseName() {
- return(databaseName);
+ public String getURL() {
+ return(url);
}
/**
- * Sets the database name
+ * Sets the connection URL
*
- * @param databaseName the database name
+ * @param url the connection URL
*/
- public void setDatabaseName(String databaseName) {
- this.databaseName = databaseName;
+ public void setDatabaseName(String url) {
+ this.url = url;
}
/**
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Monetdb-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-checkins