|
Hyperic HQ Plugin API v. 4.4.0.2 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.hyperic.util.jdbc.DBUtil
public class DBUtil
Field Summary | |
---|---|
static int |
DATABASE_MYSQL5
|
static int |
DATABASE_ORACLE_10
|
static int |
DATABASE_ORACLE_11
|
static int |
DATABASE_ORACLE_8
|
static int |
DATABASE_ORACLE_9
|
static int |
DATABASE_POSTGRESQL_7
|
static int |
DATABASE_POSTGRESQL_8
|
static int |
DATABASE_UNKNOWN
|
static int |
IN_CHUNK_SIZE
|
protected static org.apache.commons.logging.Log |
log
|
static int |
MYSQL_LOCAL_CONN_ERROR
|
static int |
MYSQL_REMOTE_CONN_ERROR
|
static int |
ORACLE_ERROR_DIVIDE_BY_ZERO
|
static int |
ORACLE_ERROR_NOT_AVAILABLE
|
static int |
POSTGRES_CONNECTION_EXCEPTION
|
static int |
POSTGRES_CONNECTION_FAILURE
|
static int |
POSTGRES_ERROR_DIVIDE_BY_ZERO
|
static int |
POSTGRES_UNABLE_TO_CONNECT
|
Method Summary | |
---|---|
static boolean |
checkColumnExists(java.lang.String ctx,
java.sql.Connection c,
java.lang.String table,
java.lang.String column)
Check to see if a column exists in a table. |
static boolean |
checkTableExists(java.sql.Connection conn,
java.lang.String table)
|
static boolean |
checkTableExists(java.lang.String url,
java.lang.String user,
java.lang.String password,
java.lang.String table)
|
static void |
closeConnection(java.lang.Object ctx,
java.sql.Connection c)
Close a database connection. |
static void |
closeJDBCObjects(java.lang.Object ctx,
java.sql.Connection c,
java.sql.Statement s,
java.sql.ResultSet rs)
Close a connection, statement, and result set in one fell swoop. |
static void |
closeResultSet(java.lang.Object ctx,
java.sql.ResultSet rs)
Close a database result set. |
static void |
closeStatement(java.lang.Object ctx,
java.sql.Statement s)
Close a database statement. |
static java.lang.String |
composeConjunctions(java.lang.String column,
int iterations)
Creates the SQL query that is used in PreparedStatement for 0 or more values for a given column. |
static byte[] |
getBlobColumn(java.sql.ResultSet rs,
int columnIndex)
Get a database specific blob column, when you already have the result set open |
static java.lang.String |
getBooleanType(java.sql.Connection conn)
Get the type for a boolean as a string for the required database. |
static java.lang.String |
getBooleanValue(boolean bool,
java.sql.Connection conn)
Get the value for a boolean as a string for the required database |
static java.sql.Connection |
getConnByContext(javax.naming.Context jndiCtx,
java.lang.String dsName)
get a connection for a datasource registered in JNDI |
static int |
getDBType(java.sql.Connection conn)
Given a Connection object, this method returns a constant indicating what type of database the Connection is connected to. |
static int |
getNextSequenceValue(java.lang.String ctx,
java.sql.Connection conn,
java.lang.String table,
java.lang.String key)
Get the next value of a sequence |
static boolean |
isMySQL(java.sql.Connection c)
Is the database MySQL? |
static boolean |
isMySQL(int type)
|
static boolean |
isOracle(java.sql.Connection c)
Is the database Oracle? |
static boolean |
isOracle(int type)
|
static boolean |
isPostgreSQL(java.sql.Connection c)
Is the database PostgreSQL? |
static boolean |
isPostgreSQL(int type)
|
static void |
replacePlaceHolder(java.lang.StringBuffer buf,
java.lang.String repl)
|
static void |
replacePlaceHolders(java.lang.StringBuffer buf,
java.lang.Object[] objs)
|
static int |
seek(java.sql.ResultSet rs,
PageControl pc)
Seek through the specified ResultSet to the beginning of the page specified by the PageControl |
static void |
setBooleanValue(boolean bool,
java.sql.Connection conn,
java.sql.PreparedStatement ps,
int idx)
Fill out a PreparedStatement correctly with a boolean. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final org.apache.commons.logging.Log log
public static final int ORACLE_ERROR_DIVIDE_BY_ZERO
public static final int ORACLE_ERROR_NOT_AVAILABLE
public static final int POSTGRES_ERROR_DIVIDE_BY_ZERO
public static final int POSTGRES_CONNECTION_EXCEPTION
public static final int POSTGRES_CONNECTION_FAILURE
public static final int POSTGRES_UNABLE_TO_CONNECT
public static final int MYSQL_LOCAL_CONN_ERROR
public static final int MYSQL_REMOTE_CONN_ERROR
public static final int DATABASE_UNKNOWN
public static final int DATABASE_POSTGRESQL_7
public static final int DATABASE_POSTGRESQL_8
public static final int DATABASE_ORACLE_8
public static final int DATABASE_ORACLE_9
public static final int DATABASE_ORACLE_10
public static final int DATABASE_ORACLE_11
public static final int DATABASE_MYSQL5
public static final int IN_CHUNK_SIZE
Method Detail |
---|
public static void closeConnection(java.lang.Object ctx, java.sql.Connection c)
ctx
- The logging context to use if a warning should be issued.c
- The connection to close.public static void closeStatement(java.lang.Object ctx, java.sql.Statement s)
ctx
- The logging context to use if a warning should be issued.s
- The statement to close.public static void closeResultSet(java.lang.Object ctx, java.sql.ResultSet rs)
ctx
- The logging context to use if a warning should be issued.rs
- The result set to close.public static void closeJDBCObjects(java.lang.Object ctx, java.sql.Connection c, java.sql.Statement s, java.sql.ResultSet rs)
ctx
- The logging context to use if warnings should be issued.c
- The connection to close.s
- The statement set to close.rs
- The result set to close.public static int getNextSequenceValue(java.lang.String ctx, java.sql.Connection conn, java.lang.String table, java.lang.String key) throws java.sql.SQLException
java.sql.SQLException
public static int getDBType(java.sql.Connection conn) throws java.sql.SQLException
conn
- The connection whose database type the caller wished to
ascertain.
java.sql.SQLException
public static boolean isPostgreSQL(java.sql.Connection c) throws java.sql.SQLException
java.sql.SQLException
public static boolean isPostgreSQL(int type)
public static boolean isOracle(java.sql.Connection c) throws java.sql.SQLException
java.sql.SQLException
public static boolean isOracle(int type)
public static boolean isMySQL(java.sql.Connection c) throws java.sql.SQLException
java.sql.SQLException
public static boolean isMySQL(int type)
public static java.sql.Connection getConnByContext(javax.naming.Context jndiCtx, java.lang.String dsName) throws java.sql.SQLException, javax.naming.NamingException
java.sql.SQLException
javax.naming.NamingException
public static byte[] getBlobColumn(java.sql.ResultSet rs, int columnIndex) throws java.sql.SQLException
columnIndex
- where to read the blob column form.
java.sql.SQLException
public static java.lang.String getBooleanType(java.sql.Connection conn) throws java.sql.SQLException
conn
- - a connection
java.sql.SQLException
public static java.lang.String getBooleanValue(boolean bool, java.sql.Connection conn) throws java.sql.SQLException
bool
- - the boolean you wantconn
- - a connection
java.sql.SQLException
public static void setBooleanValue(boolean bool, java.sql.Connection conn, java.sql.PreparedStatement ps, int idx) throws java.sql.SQLException
bool
- - the boolean you wantconn
- - a connection
java.sql.SQLException
public static int seek(java.sql.ResultSet rs, PageControl pc) throws java.sql.SQLException
rs
- The result set to seek through.pc
- The page control that indicates how far to seek
java.sql.SQLException
public static boolean checkColumnExists(java.lang.String ctx, java.sql.Connection c, java.lang.String table, java.lang.String column) throws java.sql.SQLException
ctx
- The logging context to use.c
- The DB connection to use.table
- The table to check.column
- The column to look for. This is done in a case-insensitive
manner.
java.sql.SQLException
- If any kind of DB error occurs.public static boolean checkTableExists(java.lang.String url, java.lang.String user, java.lang.String password, java.lang.String table) throws DriverLoadException, java.sql.SQLException
DriverLoadException
java.sql.SQLException
public static boolean checkTableExists(java.sql.Connection conn, java.lang.String table) throws java.sql.SQLException
java.sql.SQLException
public static java.lang.String composeConjunctions(java.lang.String column, int iterations)
column
- the name of the column to query againstiterations
- the number of variables
public static void replacePlaceHolder(java.lang.StringBuffer buf, java.lang.String repl)
public static void replacePlaceHolders(java.lang.StringBuffer buf, java.lang.Object[] objs)
|
Hyperic HQ Plugin API v. 4.4.0.2 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |