JBoss.orgCommunity Documentation

Chapter 4. Connection Management

4.1. Default Connection Properties
4.2. Handling Multiple Connections

The file "connection.properties" in the installation directory of the MMAdmin defines the default connection properties with which user can connect to Teiid system. The following  properties can be defined using this file

server.host = <server host name or ip address>
server.port = <server port number>
user.name = <user name>
user.password = <password>
vdb.name = <vdb name>    

When properties file is found, a call to "connect()" without any input parameters, will connect to the Teiid system using the properties defined in properties file. However, user can always pass in parameters in the connect method to connect to a same or different server than one mentioned in the “connection.properties”.  Look all the all the different connect methods using the “help()” method.  

Note that it is not secure to leave the passwords in clear text, as defined above. Please take necessary measures to secure the properties file, or do not use this feature and always pass in password interactively or some other secure way.

Note: At any given time user can be actively connected to more than one system or have more than one connection to same system.  To manage the connections correctly each connection is created given a unique connection name. To learn more about this look at Handling multiple Connections section.

Using MMAdmin, user can actively manage more than one connection to a single or multiple Teiid systems. For example, two separate connections can be maintained, one to the development server and one to the integration server at the same time. This is possible because MMAdmin supports a feature called named connections.

Every time a connection is made, it assigns a unique name to that connection and manages the context  of the connection under that name.  Unless, user makes another connection all the commands executed after the connection is made will use that connection.  If another connect command is executed then a new connection is made with a unique name and execution will be switched to use the new connection that has been created.  The previous connection will be held as it is in its current state, and will not be closed.

In the interactive mode the name of the connection can found in the command prompt.  Also, you could use the following command in the interactive and script mode to find out the current connection's name

name = currentConnectionName();    

Knowing the names of the connection that user is working with is important, as this would enable user to switch the active connection that they have currently working with another connection they have previously made.  To switch the active connection, use the following command and supply the name of the connection to be used


If user supplies the same name as the active connection as they are currently participating in, then this operation will simply return with out any modifications. There is no limitation as to how many simultaneous connections that user can maintain, this is up to the script developer.

The following shows an example of using and switching between two connections.

// creates a connection 

//capture the connection name
conn1 = currentConnectionName();

// run a SQL command using "conn1"
select * from table;	

// creates a second connection 

conn2 = currentConnectionName();

// runs a SQL command on the connection "conn2"
select * from table;	
// switch the connection to "conn1"

// run the SQL command using connection "conn1"
select * from table;	

// close the connection in the "conn1"

// switch to "conn2"