com.hp.ucmdb.discovery.library.clients.query
Class SqlClient

java.lang.Object
  extended by com.hp.ucmdb.discovery.library.clients.BaseClient
      extended by com.hp.ucmdb.discovery.library.clients.query.QueryClient
          extended by com.hp.ucmdb.discovery.library.clients.query.SqlClient

public class SqlClient
extends QueryClient

The SqlClient class provides the basic APIs for database queries. SqlClient works with ORACLE, SYBASE, MS SQL server, and DB2.
Methods that interact with the database use the timeout from the credentials unless a timeout is passed explicitly to the method.
See the example in the QueryClient reference.

See Also:
QueryClient

Field Summary
static java.lang.String JDBC_RESOURCE_DIR
           
static java.lang.String UAVAILABLE_DB_VERSION
           
 
Fields inherited from class com.hp.ucmdb.discovery.library.clients.BaseClient
CREDENTIALS_ID, ENCODING
 
Constructor Summary
SqlClient(ClientsFrameworkImpl framework, java.util.Properties props)
           
 
Method Summary
 ResultSet doCall(java.lang.String sqlStatement)
          Executes a Select or Update query.
 ResultSet doCall(java.lang.String sqlStatement, int queryTimeout)
          Executes a Select or Update query with the specified timeout.
 ResultSet executeQuery(java.lang.String query)
          Executes a Select query.
 ResultSet executeQuery(java.lang.String query, int queryTimeout)
          Executes a Select query with the specified timeout.
 java.lang.String getAppVersion()
          Returns the version of the database to which the client is connected.
 java.lang.String getDatabaseName()
          Returns Oracle SID or the database name from the protocol definition.
 java.lang.String getDbVersion()
          Returns the database version number.
 int getPort()
          Returns the port on which the database server listens.
 java.lang.String getProtocolDbType()
          Returns the database type.
 java.lang.String getSid()
          Returns the Database System ID(database instance name)
 ResultSet getTable(java.lang.String query)
          Deprecated. use executeQuery(java.lang.String)
 ResultSet getTable(java.lang.String query, int queryTimeout)
          Deprecated. use executeQuery(java.lang.String)
 java.lang.String getWorkingDatabase()
          Returns the name of the schema to which the client is connected.
 void setWorkingDatabase(java.lang.String dbName)
          Sets the database schema name to which the client connects.
 
Methods inherited from class com.hp.ucmdb.discovery.library.clients.BaseClient
close, getClientType, getCredentialId, getIpAddress, getProperty, getShellCmdSeperator, getSudoCommands, getSudoPaths, getTimeout, getUserName, isConnected, supportsSudo
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

JDBC_RESOURCE_DIR

public static final java.lang.String JDBC_RESOURCE_DIR

UAVAILABLE_DB_VERSION

public static final java.lang.String UAVAILABLE_DB_VERSION
See Also:
Constant Field Values
Constructor Detail

SqlClient

public SqlClient(ClientsFrameworkImpl framework,
                 java.util.Properties props)
          throws java.lang.Exception
Throws:
java.lang.Exception
Method Detail

getSid

public java.lang.String getSid()
Returns the Database System ID(database instance name)

Returns:
The SID if found, or an empty string

getDatabaseName

public java.lang.String getDatabaseName()
Returns Oracle SID or the database name from the protocol definition. If there is no database name in the protocol definition, the protocol name is returned.

Returns:
A SID, database name, or protocol name

setWorkingDatabase

public void setWorkingDatabase(java.lang.String dbName)
                        throws java.lang.Exception
Sets the database schema name to which the client connects.

Parameters:
dbName - The schema name
Throws:
java.lang.Exception

getWorkingDatabase

public java.lang.String getWorkingDatabase()
                                    throws java.lang.Exception
Returns the name of the schema to which the client is connected. getWorkingDatabase uses the database specified in the credentials.

Returns:
The schema name
Throws:
java.lang.Exception

executeQuery

public ResultSet executeQuery(java.lang.String query)
                       throws java.lang.Exception
Executes a Select query.
Warning: Close the ResultSet when finished processing data.

Overrides:
executeQuery in class QueryClient
Parameters:
query - An SQL query statement
Returns:
A ResultSet
Throws:
java.lang.Exception
See Also:
ResultSet

executeQuery

public ResultSet executeQuery(java.lang.String query,
                              int queryTimeout)
                       throws java.lang.Exception
Executes a Select query with the specified timeout.
Warning: Close the ResultSet when finished processing data.

Parameters:
query - An SQL query statement
queryTimeout - The timeout in milliseconds
Returns:
A ResultSet
Throws:
java.lang.Exception
See Also:
ResultSet

getTable

public ResultSet getTable(java.lang.String query)
                   throws java.lang.Exception
Deprecated. use executeQuery(java.lang.String)

Executes a Select query.
Warning: Close the ResultSet when finished processing data.

Parameters:
query - sql query statement
Returns:
The ResultSet
Throws:
java.lang.Exception
See Also:
ResultSet

getTable

public ResultSet getTable(java.lang.String query,
                          int queryTimeout)
                   throws java.lang.Exception
Deprecated. use executeQuery(java.lang.String)

Executes a Select query.
Warning: Close the ResultSet when finished processing data.

Parameters:
query - sql query statement
queryTimeout - The timeout in milliseconds
Returns:
The ResultSet
Throws:
java.lang.Exception
See Also:
ResultSet

doCall

public ResultSet doCall(java.lang.String sqlStatement)
                 throws java.lang.Exception
Executes a Select or Update query.
Warning: Close the ResultSet when finished processing data.

Parameters:
sqlStatement - An SQL statement
Returns:
A ResultSet
Throws:
java.lang.Exception
See Also:
ResultSet

doCall

public ResultSet doCall(java.lang.String sqlStatement,
                        int queryTimeout)
                 throws java.lang.Exception
Executes a Select or Update query with the specified timeout.
Warning: Close the ResultSet when finished processing data.

Parameters:
sqlStatement - An SQL statement
queryTimeout - The timeout in milliseconds
Returns:
A ResultSet
Throws:
java.lang.Exception
See Also:
ResultSet

getProtocolDbType

public java.lang.String getProtocolDbType()
Returns the database type. The type is specified in the protocol definition.

Returns:
The database type name

getPort

public int getPort()
Returns the port on which the database server listens. The port is specified in the protocol definition.

Returns:
The port number

getDbVersion

public java.lang.String getDbVersion()
Returns the database version number.


getAppVersion

public java.lang.String getAppVersion()
Returns the version of the database to which the client is connected.



Documentation Feedback
Copyright 2010 Hewlett-Packard Development Company, L.P.