Author: rareddy
Date: 2009-07-07 17:25:59 -0400 (Tue, 07 Jul 2009)
New Revision: 1102
Modified:
trunk/adminshell/src/main/resources/scripts/jdbc.bsh
trunk/adminshell/src/main/resources/scripts/server.bsh
trunk/build/kit-adminshell/connection.properties
Log:
TEIID-698: Simplifying the connection parameters in the connection.properties
Modified: trunk/adminshell/src/main/resources/scripts/jdbc.bsh
===================================================================
--- trunk/adminshell/src/main/resources/scripts/jdbc.bsh 2009-07-07 20:52:42 UTC (rev
1101)
+++ trunk/adminshell/src/main/resources/scripts/jdbc.bsh 2009-07-07 21:25:59 UTC (rev
1102)
@@ -134,11 +134,11 @@
private checkConnection() {
context = currentContext();
if (context == void || context == null) {
- throw new Exception("Not connected. You must call a \"connect\"
method");
+ throw new Exception("Not connected. You must call a \"connect\"
method first");
}
if (context.internalConnection == void || context.internalConnection == null) {
- throw new Exception ("Not connected. You must call a \"connect\"
method");
+ throw new Exception ("Not connected. You must call a \"connect\"
method first");
}
}
/**
Modified: trunk/adminshell/src/main/resources/scripts/server.bsh
===================================================================
--- trunk/adminshell/src/main/resources/scripts/server.bsh 2009-07-07 20:52:42 UTC (rev
1101)
+++ trunk/adminshell/src/main/resources/scripts/server.bsh 2009-07-07 21:25:59 UTC (rev
1102)
@@ -7,17 +7,16 @@
import java.sql.*;
+import com.metamatrix.common.api.MMURL;
+import com.metamatrix.common.comm.platform.client.ServerAdminFactory;
// These values are default values, a user can supply a property file called
// "connection.properties" those values will replace one below
-String user_host = InetAddress.getLocalHost().getHostName();
-int user_port = 31000;
-String user_id = "admin";
-String user_pwd = "teiid";
-String user_protocol = "mm:"; // colon is important
-String user_driver = "org.teiid.jdbc.TeiidDriver";
-String user_vdb = "admin";
-user_optional_url="";
+String auto_jdbc_url="jdbc:teiid:admin@mm://localhost:31000";
+String auto_user="admin";
+String auto_password="teiid";
+String auto_admin_url="mm://localhost:31000";
+
String connection_prefix="conn";
/**
@@ -25,32 +24,9 @@
* use currentConnectionName() to get connection name
*/
Connection connect () {
- return connect(user_host, user_port, user_vdb, user_id, user_pwd,
user_optional_url);
+ return
connect(auto_jdbc_url+";user="+auto_user+";password="+auto_password);
}
-/**
- * Connect to the server; use currentConnectionName() to get connection name
- * @param host - host name
- * @param port - port
- * @param vdb - vdb name
- * @param user - user name
- * @param password - password for the user
- * @param optional_url - optional URL properties like txnAutoWrap etc. Need to be
semi-colon [;] separated.
- * @return Connection - connection object
- */
-Connection connect (String host, int port, String vdb, String user, String password,
String optional_url) {
- String contextName = genConnectionName();
- newContext(contextName);
- String url =
"jdbc:teiid:"+vdb+"@"+user_protocol+"//"+host+":"+port+";user="+user+";password="+password+";ApplicationName="+contextName;
- if (optional_url != null && optional_url.length() > 0) {
- url = url + ";" + optional_url;
- }
- com.metamatrix.jdbc.api.Connection mmConn = connectDriver(user_driver, url);
- currentContext().internalAdmin = createExceptionHandlingProxy(mmConn.getAdminAPI());
- currentContext().internalPrompt =
contextName+"["+vdb+"@"+host+"] $ ";
- return mmConn;
-}
-
Connection connectEmbedded(String url) throws SQLException {
c = connectURL(url, "com.metamatrix.jdbc.EmbeddedDriver");
currentContext().internalPrompt = "embedded:["+extractVDBName(url)+"]$
";
@@ -58,31 +34,18 @@
}
/**
- * Current Connection Name.
- */
-String currentConnectionName() {
- if ((getConnection() != null || currentContext().internalAdmin != null) &&
currentContext().name != void && currentContext().name != null) {
- return currentContext().name;
- }
- throw new Exception("No Connection exists; or it is not a named
connection");
-}
-
-void useConnection(name) {
- useContext(name);
-}
-
-/*
- * Connect to the Server; use currentConnectionName() to get connection name
+ * Connect to the Server with supplied URL, used TeiidDriver
* @param url - complete url for connection
*/
Connection connect (String url) {
- return connectURL(url, user_driver);
+ return connectURL(url, "org.teiid.jdbc.TeiidDriver");
}
private Connection connectURL (String url, String driver) {
if (url.startsWith("jdbc:metamatrix:") ||
url.startsWith("jdbc:teiid:")) {
String contextName = genConnectionName();
newContext(contextName);
+ url = url+";ApplicationName="+contextName;
com.metamatrix.jdbc.api.Connection mmConn = connectDriver(driver, url);
currentContext().internalPrompt =
contextName+"["+extractVDBName(url)+"@"+extractHost(url)+"] $
";
currentContext().internalAdmin =
createExceptionHandlingProxy(mmConn.getAdminAPI());
@@ -94,6 +57,20 @@
}
/**
+ * Current Connection Name.
+ */
+String currentConnectionName() {
+ if ((getConnection() != null || currentContext().internalAdmin != null) &&
currentContext().name != void && currentContext().name != null) {
+ return currentContext().name;
+ }
+ throw new Exception("No Connection exists; or it is not a named
connection");
+}
+
+void useConnection(name) {
+ useContext(name);
+}
+
+/**
* Get a ServerAdmin connection to the specified server.
*
* @param username
@@ -124,7 +101,7 @@
* Connect as Admin using the defaults from connection.properties
*/
void connectAsAdmin() {
- connectAsAdmin(user_id, user_pwd,
"mm://"+user_host+":"+user_port);
+ connectAsAdmin(auto_user, auto_password, auto_admin_url);
}
/**
@@ -151,35 +128,23 @@
}catch(e) {
}
- if (p.getProperty("server.host") != null) {
- user_host = p.getProperty("server.host");
+ if (p.getProperty("jdbc.url") != null) {
+ auto_jdbc_url = p.getProperty("jdbc.url");
}
- if (p.getProperty("server.port") != null) {
- try {
- user_port = Integer.parseInt(p.getProperty("server.port"));
- }catch(e) {
- }
+ if (p.getProperty("admin.url") != null) {
+ auto_admin_url = p.getProperty("admin.url");
}
- if (p.getProperty("server.username") != null) {
- user_id = p.getProperty("server.username");
- }
+ if (p.getProperty("user") != null) {
+ auto_user = p.getProperty("user");
+ }
- if (p.getProperty("server.password") != null) {
- user_pwd = p.getProperty("server.password");
+ if (p.getProperty("password") != null) {
+ auto_password = p.getProperty("user");
+ }
}
- if (p.getProperty("vdb.name") != null) {
- user_vdb = p.getProperty("vdb.name");
- }
-
- if (p.getProperty("server.optional-url") != null) {
- user_optional_url = p.getProperty("server.optional-url");
- }
-
-}
-
//help methods
/**
Modified: trunk/build/kit-adminshell/connection.properties
===================================================================
--- trunk/build/kit-adminshell/connection.properties 2009-07-07 20:52:42 UTC (rev 1101)
+++ trunk/build/kit-adminshell/connection.properties 2009-07-07 21:25:59 UTC (rev 1102)
@@ -1,6 +1,4 @@
-server.host=localhost
-server.port=31000
-server.username=admin
-server.password=teiid
-#server.optional-url=(optional)
-vdb.name=admin
+user=admin
+password=teiid
+jdbc.url=jdbc:teiid:admin@mm://localhost:31000;
+admin.url=mm://localhost:31000
\ No newline at end of file
Show replies by date