jpl.mipl.util
Class jqi

java.lang.Object
  extended byjpl.mipl.util.jqi

public class jqi
extends Object

The jqi (Java Query Inferface) class contains database utility functions for use with the MIPL database system. The main methods of interest are the getSybaseUrl(), getUserName(), and getPassword() methods.

The getSybaseUrl() method returns a string containing the Sybase JDBC URL.
The getUserName() method returns the user's database username.
The getPassword() method returns the user's password.

All of this info is contained in the jqi() class. It is stored internally in a Properties hashtable, which is not visible to the caller. The necessary info is entered by the user when the jqi constructor is called.

Example:

// create a jqi object
jqi miplDb = new jqi();

// create a database connection using the JDBC DriverManager
Connection conn = DriverManager.getConnection(
   miplDb.getSybaseUrl(),miplDb.getUserName(),
   miplDb.getPassword());

Note: Although the set methods of this class are public, it is not necessary to call them. The constructor will set the class variables at creation time.

Change Log:
6/3/02 Tina Pavlicek modified and added code by Alice Stanboli to try to retrieve the password using the password server before asking the user directly for the password.
6/14/02 Tina Pavlicek modified and added code by Elais Sayfi to retrieve the password through a GUI if the password server did not provide one
8/24/02 Tina Pavlicek disallowed setting of password in setProps method which stops users from directly sending a password retrieved from a command line. The password can now be set with the sendProps method and the onus is on the jqi user to retrieve that password securely.

9/17/2002 Tina Pavlicek moved the new JFrame and JDialog calls into the createGUI method to prevent machines running the program from trying to create a display when not necessary. 9/18/2002 Tina Pavlicek made a minor change so that jqi would work with a new version of pwdclient. 11/25/2002 Tina Pavlicek removed a command line prompt for user name to eliminate conflicts with scripts calling programs that use jqi

Version:
11/22/02
Author:
Justin Maki, Tina Pavlicek

Constructor Summary
jqi()
          Construct a jqi object.
 
Method Summary
 String getDatabase()
          Returns the database string.
 String getDbmsType()
          Returns the DbmsType string.
 String getOs()
          Returns the Operating System (OS) string.
 String getPassword()
          Returns the password string.
 String getSelCat()
          Returns the VICAR $SELCAT Unix environment variable.
 String getServer()
          Returns the server string.
 String getServerName()
          Returns the server name string.
 String getSybaseUrl()
          Returns a string containing the Sybase JDBC URL for the current database.
 String getUserName()
          Returns the username string.
static void main(String[] args)
          A small test program.
 String parseServerString(String serverName)
          Returns the server string given the server name.
 void queryProps()
           
 void sendProps(String userN, String passW, String dataB, String dbmsT, String serverN)
           
 void setDatabase(String database)
          Sets the database string.
 void setDbmsType(String dbms)
          Sets the DbmsType string.
 void setPassword(String password)
          Sets the password string.
 void setProps(String[] args)
           
 void setServerName(String serverName)
          Sets the server name string.
 void setUserName(String user)
          Sets the user name string.
 void windowDeiconified(WindowEvent e)
           
 void windowIconified(WindowEvent e)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

jqi

public jqi()
Construct a jqi object. The construction involves the following:

1. Reading a user preferences file (if it exists) called ".jqi", stored in the user's home directory.
2. Querying the user via the command line for the various required information.
3. Reading/parsing of the $SYBASE/interfaces file.

Method Detail

windowDeiconified

public void windowDeiconified(WindowEvent e)

windowIconified

public void windowIconified(WindowEvent e)

setProps

public void setProps(String[] args)

sendProps

public void sendProps(String userN,
                      String passW,
                      String dataB,
                      String dbmsT,
                      String serverN)

queryProps

public void queryProps()

getUserName

public String getUserName()
Returns the username string.

Returns:
A string containing the user name.

setUserName

public void setUserName(String user)
Sets the user name string.

Parameters:
user - A string containing the user name.

getPassword

public String getPassword()
Returns the password string.

Returns:
A string containing the password.

setPassword

public void setPassword(String password)
Sets the password string.

Parameters:
password - A string containing the password.

getServer

public String getServer()
Returns the server string.

Returns:
A string containing the server info.

getDatabase

public String getDatabase()
Returns the database string.

Returns:
A string containing the database name.

setDatabase

public void setDatabase(String database)
Sets the database string.

Parameters:
database - A string containing the database name.

getDbmsType

public String getDbmsType()
Returns the DbmsType string.

Returns:
A string containing the DBMS type.

setDbmsType

public void setDbmsType(String dbms)
Sets the DbmsType string.

Parameters:
dbms - A string containing the DBMS type.

getOs

public String getOs()
Returns the Operating System (OS) string.

Returns:
A string containing the OS name.

getServerName

public String getServerName()
Returns the server name string.

Returns:
A string containing the server name.

setServerName

public void setServerName(String serverName)
Sets the server name string.

Parameters:
serverName - A string containing the server name.

getSybaseUrl

public String getSybaseUrl()
Returns a string containing the Sybase JDBC URL for the current database. The string is constructed based on the values of the various parameters of the jqi object.

Returns:
A String containing a JDBC URL.

parseServerString

public String parseServerString(String serverName)
Returns the server string given the server name. This method goes to the $SYBASE/interfaces file and extracts the server string that correponds to the give name. It returns null if the servername is not found in the interfaces file.

Parameters:
serverName - A string containing the name of the server.
Returns:
The server string.

getSelCat

public String getSelCat()
Returns the VICAR $SELCAT Unix environment variable.

Returns:
The variable returned from the Unix command "printenv SELCAT".

main

public static void main(String[] args)
A small test program.