public class SQLHelper
extends Object
implements RemoteAccess
Modifier and Type | Field and Description |
---|---|
static String |
BLOB |
static String |
CHAR |
static Map<String,String> |
COL_TYP |
static String |
CONCATSTR |
static String |
DATE |
static String |
DBTYPE |
static String |
DBTYPE_MSSQL |
static String |
DBTYPE_ORACLE |
static boolean |
DBTYPEMSSQL |
static boolean |
DBTYPEORACLE |
static boolean |
HAS_REGEX_SUPPORT
HAS_REGEX_SUPPORT: Verification of SQL Regular Expressions support within the MSSQL database.
|
static int |
MAJOR |
static int |
MINOR |
static String |
NUM |
static String |
REGEXEXCEPTION
REGEXEXCEPTION: Returns the message of the SQL Regular Expression verification exception as string.
|
static String |
REGEXSUPPORTTEXT |
static Map<String,Map<String,String[]>> |
SS_COL_NAMES |
static Map<String,String> |
SS_TAB_NAME |
static String |
TAB_COLS |
static String |
WTHOME |
Constructor and Description |
---|
SQLHelper() |
Modifier and Type | Method and Description |
---|---|
static void |
createSeq(String name)
run a sql statement in oracle
|
static Connection |
dbConnect()
return a Connection using windchill's configured credentials
|
static Connection |
dbConnect(String user,
String pass)
return a Connection with given credentials
|
static Map<String,String> |
getCC()
get credentials for database connection from keystore
|
static String |
getColName(String table,
String col)
return column name with casing as required by database - returns unaltered String for oracle, checks dictionary for SQLServer
|
static String[] |
getColNames(String table,
String[] cols)
return column name with casing as required by database - returns unaltered Strings for oracle, checks dictionary for SQLServer
|
static void |
getCount()
find all records that match a given regex in one of their varchar cols
|
static String |
getRegexWhere(String table,
String col,
String regex,
boolean invert,
boolean ignoreCase) |
static List<String> |
grep(String[] a)
find all records that match a given regex in one of their varchar cols
|
static List<String> |
idax(String[] a)
(try to) identify all records that reference a given ida2a2
|
static void |
main(String[] a)
print program usage info or invoke testConn()
|
static void |
runSQL(String[] a)
run a sql statement with the connection info from db.properties. prints result to STDERR
|
static void |
testConn(String[] a)
allow testing of oracle connection running "select sysdate from dual", either with supplied args or the connection info from db.properties. prints result to STDERR
|
public static String WTHOME
public static final int MAJOR
public static final int MINOR
public static final String DBTYPE
public static final String DBTYPE_MSSQL
public static final String DBTYPE_ORACLE
public static final String NUM
public static final String DATE
public static final String CHAR
public static final String BLOB
public static final String CONCATSTR
public static boolean DBTYPEORACLE
public static boolean DBTYPEMSSQL
public static String REGEXSUPPORTTEXT
public static boolean HAS_REGEX_SUPPORT
public static String REGEXEXCEPTION
public static String TAB_COLS
public static Map<String,String> COL_TYP
public static Map<String,String> SS_TAB_NAME
public static Map<String,Map<String,String[]>> SS_COL_NAMES
public static String getColName(String table, String col) throws Exception
table
- table name for column lookup (same column may have different casing: name vs. NAME)col
- col name to lookupException
- if table not foundpublic static String[] getColNames(String table, String[] cols) throws Exception
table
- table name for column lookup (same column may have different casing: name vs. NAME)col
- col name to lookupException
- if table not found or a column is not foundpublic static Map<String,String> getCC() throws Exception
Exception
public static Connection dbConnect() throws Exception
Exception
public static Connection dbConnect(String user, String pass) throws Exception
Exception
public static void testConn(String[] a) throws Exception
a
- arguments, -c [host port sid user [pass]]Exception
public static void runSQL(String[] a) throws Exception
a
- arguments, -r statementException
public static List<String> idax(String[] a) throws Exception
a
- arguments, ida2a2 [[-n] tab-name-regex]Exception
public static List<String> grep(String[] a) throws Exception
a
- arguments, col-regex [[-n] tab-name-regex]Exception
public static void getCount() throws Exception
a
- arguments, col-regex [[-n] tab-name-regex]Exception
public static void createSeq(String name) throws Exception
name
- name of sequence to createException
public static String getRegexWhere(String table, String col, String regex, boolean invert, boolean ignoreCase) throws Exception
Exception
public static void main(String[] a) throws Exception
a
- commandline argsException