NetCharts Server

chartworks.es.plugin
Class GetJdbcData

java.lang.Object
  |
  +--chartworks.es.plugin.GetJdbcData
Direct Known Subclasses:
GetOracleJdbcData

public class GetJdbcData
extends java.lang.Object

GetJdbcData is a general class used to extract data from any Jdbc data source. Callers should minimally invoke setServerURLBase setDriverName setDBName OR setJNDILookupName before making any calls to the other methods with the exception of the stringQuery and printQuery convenience calls. By default, GetJdbcData will attempt to use the Jdbc-Odbc bridge if no other driver is specified.


Field Summary
static java.lang.String JDBC_ODBC_DRIVER_NAME
           
 
Constructor Summary
GetJdbcData()
           
 
Method Summary
 boolean connectionIsValid(java.sql.Connection connection)
           
 void executeJdbc(java.lang.String dbName, java.lang.String sql, java.util.Vector rows)
          Execute a Jdbc statement
 void executeJdbc(java.lang.String sql, java.util.Vector rows)
          Execute a Jdbc statement
static java.util.Date getDate(java.sql.ResultSet rs, java.sql.ResultSetMetaData rsmd, int i)
           
static boolean isDate(java.sql.ResultSetMetaData rsmd, int i)
           
static void main(java.lang.String[] args)
           
 void printQuery(java.lang.String dbName, java.lang.String sql, java.io.PrintWriter p)
          printQuery executes the given SQL statement and writes the output to the given PrintWriter
 void setDateFormat(java.lang.String dateFormat)
          Allows specification of date format
 void setDBName(java.lang.String dbName)
          Sets the Database or DSN name.
 void setDriverName(java.lang.String driverName)
          Sets the JDBC driver name
 void setIncludeColumnNames(java.lang.String includeColumnNames)
          If true, the first row of the result set will be the column label/name.
 void setJNDIInitialContextFactory(java.lang.String jndiInitialContextFactory)
          Sets the JNDI Initial Context Factory class name.
 void setJNDILookupName(java.lang.String jndiLookupName)
          Sets the JNDI lookup name.
 void setLoginAndPassword(java.lang.String login, java.lang.String password)
          Sets the login and password to be used when logging into the server
 void setMultipleResults(boolean multipleResults)
          Sets whether or not to process multiple result sets/update counts.
 void setMultipleResults(java.lang.String multipleResults)
          Sets whether or not to process multiple result sets/update counts.
 void setNullString(java.lang.String nullString)
          Sets the string to use if the database contains a null
 void setProperties(java.lang.String properties)
          Allows users to pass in property values to be used at connection time.
 void setServerURLBase(java.lang.String serverURLBase)
          Sets the base part of the server URL, for example "jdbc:odbc:" for the JDBC-ODBC bridge.
 void setSimpleDateFormat(java.lang.String dateFormat)
          Allows specification of simple date format
 void setSkipNulls(boolean skipNulls)
          Sets whether or not null items should be added to the output.
 void setSkipNulls(java.lang.String skipNulls)
          Sets whether or not null items should be added to the output.
 void setStayAlive(boolean stayAlive)
          Determines if concurrent queries should use the same connection.
 void setStayAlive(java.lang.String stayAlive)
          Determines if concurrent queries should use the same connection.
 void setStdoutDebuggingOn(boolean stdoutDebuggingOn)
          Allows debugging messages to be written to standard output.
 void setStdoutDebuggingOn(java.lang.String stdoutDebuggingOn)
          Allows debugging messages to be written to standard output.
 java.lang.StringBuffer stringQuery(java.lang.String dbName, java.lang.String sql)
          stringQuery executes the given SQL statement and returns a StringBuffer with the result data.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

JDBC_ODBC_DRIVER_NAME

public static final java.lang.String JDBC_ODBC_DRIVER_NAME
Constructor Detail

GetJdbcData

public GetJdbcData()
Method Detail

stringQuery

public java.lang.StringBuffer stringQuery(java.lang.String dbName,
                                          java.lang.String sql)
stringQuery executes the given SQL statement and returns a StringBuffer with the result data.
Parameters:
dbName - The name of the database or DSN
sql - The select statement

printQuery

public void printQuery(java.lang.String dbName,
                       java.lang.String sql,
                       java.io.PrintWriter p)
printQuery executes the given SQL statement and writes the output to the given PrintWriter
Parameters:
dbName - The name of the database or DSN
sql - The select statement
p - The output object to write the results to

setServerURLBase

public void setServerURLBase(java.lang.String serverURLBase)
Sets the base part of the server URL, for example "jdbc:odbc:" for the JDBC-ODBC bridge. When a connection is made, the serverURLBase is concatenated with the database name to make the complete serverURL name.
Parameters:
serverURLBase - The JDBC server URL base. If not set, "jdbc:odbc:" is used.

setNullString

public void setNullString(java.lang.String nullString)
Sets the string to use if the database contains a null
Parameters:
nullString - Null string. If not set, "null" is used.

setDriverName

public void setDriverName(java.lang.String driverName)
Sets the JDBC driver name
Parameters:
driverName - JDBC driver name. If not set, "sun.jdbc.odbc.JdbcOdbcDriver" is used.

setDBName

public void setDBName(java.lang.String dbName)
Sets the Database or DSN name. When a connection is made, the serverURLBase is concatenated with the dbName to make the complete serverURL name.
Parameters:
dbName - Database or DSN name

setJNDIInitialContextFactory

public void setJNDIInitialContextFactory(java.lang.String jndiInitialContextFactory)
Sets the JNDI Initial Context Factory class name. When this is set, a javax.sql.DataSource is looked up using the context created using this class name and the JNDI lookup name.
Parameters:
jndiInitialContextFactory - JNDI Initial Context Factory class name.

setJNDILookupName

public void setJNDILookupName(java.lang.String jndiLookupName)
Sets the JNDI lookup name. When this is set, a javax.sql.DataSource is looked up using the context created using the JNDI Initial Context Factory and this name.
Parameters:
jndiLookupName - JNDI lookup name of the javax.sql.DataSource.

setLoginAndPassword

public void setLoginAndPassword(java.lang.String login,
                                java.lang.String password)
Sets the login and password to be used when logging into the server
Parameters:
login - database user name
password - database user password

setSkipNulls

public void setSkipNulls(java.lang.String skipNulls)
Sets whether or not null items should be added to the output.
Parameters:
skipNulls - if true, and the query result returns a null, the string "null" will be added to the output. If false and the query result returns a null, nothing is added to the output.

setSkipNulls

public void setSkipNulls(boolean skipNulls)
Sets whether or not null items should be added to the output.
Parameters:
skipNulls - if true, and the query result returns a null, the string "null" will be added to the output. If false and the query result returns a null, nothing is added to the output.

setMultipleResults

public void setMultipleResults(java.lang.String multipleResults)
Sets whether or not to process multiple result sets/update counts.
Parameters:
multipleResults - if true multiple results are processed, otherwise only the first results is processed.

setMultipleResults

public void setMultipleResults(boolean multipleResults)
Sets whether or not to process multiple result sets/update counts.
Parameters:
multipleResults - if true multiple results are processed, otherwise only the first results is processed.

setStayAlive

public void setStayAlive(java.lang.String stayAlive)
Determines if concurrent queries should use the same connection.
Parameters:
stayAlive - If true, connection will not be closed between calls to executeJdbc()

setStayAlive

public void setStayAlive(boolean stayAlive)
Determines if concurrent queries should use the same connection.
Parameters:
stayAlive - If true, connection will not be closed between calls to executeJdbc()

setProperties

public void setProperties(java.lang.String properties)
Allows users to pass in property values to be used at connection time. The properties are formatted as: [propName1]:[propValue1]&&[propName2]:[propValue2]||...
Parameters:
properties - List of connection properties.

setDateFormat

public void setDateFormat(java.lang.String dateFormat)
Allows specification of date format
Parameters:
dateFormat - - Date format string - detailed in NetCharts documentation

setSimpleDateFormat

public void setSimpleDateFormat(java.lang.String dateFormat)
Allows specification of simple date format
Parameters:
dateFormat - - Date format string - detailed in Java SimpleDateFormat doc.

setStdoutDebuggingOn

public void setStdoutDebuggingOn(java.lang.String stdoutDebuggingOn)
Allows debugging messages to be written to standard output. Note that debug consoles do not use this parameter.
Parameters:
stdoutDebuggingOn - - If true, write out debugging messages

setStdoutDebuggingOn

public void setStdoutDebuggingOn(boolean stdoutDebuggingOn)
Allows debugging messages to be written to standard output. Note that debug consoles do not use this parameter.
Parameters:
stdoutDebuggingOn - - If true, write out debugging messages

setIncludeColumnNames

public void setIncludeColumnNames(java.lang.String includeColumnNames)
If true, the first row of the result set will be the column label/name.
Parameters:
includeColumnNames - If true get the column label or name

executeJdbc

public void executeJdbc(java.lang.String dbName,
                        java.lang.String sql,
                        java.util.Vector rows)
                 throws java.lang.Exception
Execute a Jdbc statement
Parameters:
dbName - Name of database to append to serverURLBase
sql - Select or other SQL statement
rows - The output structure consisting of a vector containing a vector for each output row.

executeJdbc

public void executeJdbc(java.lang.String sql,
                        java.util.Vector rows)
                 throws java.lang.Exception
Execute a Jdbc statement
Parameters:
sql - Select or other SQL statement
rows - The output structure consisting of a vector containing a vector for each output row.

connectionIsValid

public boolean connectionIsValid(java.sql.Connection connection)

main

public static void main(java.lang.String[] args)

isDate

public static boolean isDate(java.sql.ResultSetMetaData rsmd,
                             int i)
                      throws java.sql.SQLException

getDate

public static java.util.Date getDate(java.sql.ResultSet rs,
                                     java.sql.ResultSetMetaData rsmd,
                                     int i)
                              throws java.sql.SQLException

NetCharts Server


Visual Mining, Inc.
15825 Shady Grove Rd.
Suite 20
Rockville, MD 20850
800.308.0731
301.947.8293 FAX

Copyright © Visual Mining, Inc. 1996 - 2006
All Rights Reserved.

NetCharts Server TM is a registered trademark of Visual Mining, Inc. Other brands and their products are trademarks of their respective holders.

Last Modified: Nov 26, 2006