[kepler-code] r28754 - trunk/modules/actors/src/org/geon
crawl at ecoinformatics.org
crawl at ecoinformatics.org
Tue Oct 4 11:49:00 PDT 2011
Author: crawl
Date: 2011-10-04 11:49:00 -0700 (Tue, 04 Oct 2011)
New Revision: 28754
Modified:
trunk/modules/actors/src/org/geon/OpenDBConnection.java
Log:
removing choices for sybase and "remote ms access" since they are not implemented.
adding better error message when jdbc driver can't be found.
Modified: trunk/modules/actors/src/org/geon/OpenDBConnection.java
===================================================================
--- trunk/modules/actors/src/org/geon/OpenDBConnection.java 2011-10-04 18:00:38 UTC (rev 28753)
+++ trunk/modules/actors/src/org/geon/OpenDBConnection.java 2011-10-04 18:49:00 UTC (rev 28754)
@@ -103,11 +103,9 @@
databaseFormat.addChoice("Oracle");
databaseFormat.addChoice("DB2");
databaseFormat.addChoice("Local MS Access");
- databaseFormat.addChoice("Remote MS Access (using objectweb server)");
databaseFormat.addChoice("MS SQL Server");
databaseFormat.addChoice("PostgreSQL");
databaseFormat.addChoice("MySQL");
- databaseFormat.addChoice("Sybase SQL Anywhere");
databaseFormat.addChoice("HSQL");
databaseFormat.addChoice("SQLite");
_dbFormat = _DBType._ORCL;
@@ -178,17 +176,12 @@
_dbFormat = _DBType._DB2;
} else if (dbFormat.equals("Local MS Access")) {
_dbFormat = _DBType._LACCS;
- } else if (dbFormat.startsWith("Remote MS Access")) {
- _dbFormat = _DBType._RACCS;
} else if (dbFormat.equals("MS SQL Server")) {
_dbFormat = _DBType._MSSQL;
} else if (dbFormat.equals("PostgreSQL")) {
_dbFormat = _DBType._PGSQL;
} else if (dbFormat.equals("MySQL")) {
_dbFormat = _DBType._MYSQL;
- // } else if (dbFormat.equals("Sybase SQL Anywhere")) {
- // TODO: To be added..
- // _dbFormat = _SYBASE;
} else if (dbFormat.equals("HSQL")) {
_dbFormat = _DBType._HSQL;
} else if (dbFormat.equals("SQLite")){
@@ -233,8 +226,8 @@
public void connectionsChanged(Port port) {
super.connectionsChanged(port);
if (port == dbcon) {
- List conPortsList = dbcon.connectedPortList();
- Iterator conPorts = conPortsList.iterator();
+ List<?> conPortsList = dbcon.connectedPortList();
+ Iterator<?> conPorts = conPortsList.iterator();
while (conPorts.hasNext()) {
IOPort p = (IOPort) conPorts.next();
if (p.isInput()) {
@@ -306,12 +299,27 @@
/** Get a JDBC Connection from a database parameter token. */
public static Connection getConnection(RecordToken params)
throws IllegalActionException {
+
try {
Connection retval = null;
String driver = ((StringToken) params.get("driver")).stringValue();
- Class.forName(driver).newInstance();
+ try {
+ Class.forName(driver).newInstance();
+ } catch (ClassNotFoundException e) {
+ throw new IllegalActionException(
+ "The JDBC class "
+ + driver
+ + " was not found on the classpath. One "
+ + "possible reason for this error is "
+ + "the JDBC jar is missing. Several JDBC "
+ + "jars are released under licenses "
+ + "incompatible with Kepler's license. In "
+ + "these cases, the jar must be downloaded "
+ + "manually and placed in core/lib/jar/dbdrivers.");
+ }
+
String user = _getParamField(params, "user");
String passwd = _getParamField(params, "password");
String url = _getParamField(params, "url");
@@ -324,9 +332,6 @@
return retval;
- } catch (ClassNotFoundException e) {
- throw new IllegalActionException(e.getClass().getName() + ": "
- + e.getMessage());
} catch (InstantiationException e) {
throw new IllegalActionException(e.getClass().getName() + ": "
+ e.getMessage());
@@ -358,11 +363,9 @@
RecordToken token = _createParamsToken(_driverName, _databaseURL,
_username, _password);
retval = getConnection(token);
- } catch (Exception e) {
+ } catch (IllegalActionException e) {
if (context.equals("fire"))
- throw new IllegalActionException(this, e, e.getClass()
- .getName()
- + ": " + e.getMessage());
+ throw new IllegalActionException(this, e.getCause(), e.getMessage());
}
return retval;
@@ -549,9 +552,6 @@
_databaseURL = "jdbc:odbc:" + _databaseURL;
}
break;
- case _RACCS:
- // TODO: TAKE CARE OF HOW TO SPECIFY DRIVER FOR REMOTE ACCESS DB.
- break;
case _MSSQL:
if (!_databaseURL.trim().startsWith("jdbc:sqlserver:")) {
_databaseURL = "jdbc:sqlserver:" + _databaseURL;
@@ -570,9 +570,6 @@
_databaseURL = "jdbc:mysql:" + _databaseURL;
}
break;
- case _SYBASE:
- // TODO: To be added..
- break;
case _HSQL:
if (!_databaseURL.trim().startsWith("jdbc:hsqldb:")) {
_databaseURL = "jdbc:hsqldb:" + _databaseURL;
@@ -630,10 +627,10 @@
// database types
private enum _DBType {
- _ORCL, _DB2, _LACCS, _RACCS, _MSSQL, _PGSQL, _MYSQL, _SYBASE, _HSQL,_SQLite
+ _ORCL, _DB2, _LACCS, _MSSQL, _PGSQL, _MYSQL, _HSQL, _SQLite
};
/** The database parameter token labels. */
private static String[] _paramsLabels = new String[] { "driver", "url",
"user", "password" };
-}
\ No newline at end of file
+}
More information about the Kepler-cvs
mailing list