Package com.thortech.xl.util.adapters
Class tcUtilJDBCOperations
java.lang.Object
com.thortech.xl.util.adapters.tcUtilJDBCOperations
This class that has JDBC Operations and compliments the tcUtilJDBCClass
class Authors: Louis Cheng and Jatan Rajvanshi August 1, 2002.
-
Constructor Summary
ConstructorsConstructorDescriptionDefault ConstructortcUtilJDBCOperations
(String psDriver, String psUrl, String psUsername, String psPassword) Contructor that sets the parameters for connecting to a database -
Method Summary
Modifier and TypeMethodDescriptiongetMaxStringValueFromPatternMatch
(String psTableName, String psColumnName, String psBeforeWildCard, String psAfterWildCard) Retrieves the maximum value within a group of results that match a specified as psBeforeWildCard%psAfterWildCard.getRandomRow
(String psTablename, String psColumnname, String psConstraint, String psValue) Executes a simple select statement to get back a single column from a single table for a double constraint-value pair If more than one record is returned, this method returns any one of the records at random.Hence the name The following query is executed: SELECT columnname FROM tablename WHERE firstConstraint=firstValuestatic void
Main MethodselectStatementDoubleConstraints
(String psTablename, String psColumnname, String psFirstConstraint, String psFirstValue, String psSecondConstraint, String psSecondValue) Executes a simple select statement to get back a single column from a single table for a double constraint-value pair If more than one record is returned, this method returns the first record.The following query is executed: SELECT columnname FROM tablename WHERE firstConstraint=firstValue AND secondConstraint=secondValueselectStatementSingleConstraint
(String psTablename, String psColumnname, String psConstraint, String psValue) Executes a simple select statement to get back a single column from a single table for a single constraint-value pair If more than one record is returned, this method returns the first record.The following query is executed: SELECT columnname FROM tablename WHERE constraint=value
-
Constructor Details
-
tcUtilJDBCOperations
public tcUtilJDBCOperations()Default Constructor -
tcUtilJDBCOperations
Contructor that sets the parameters for connecting to a database- Parameters:
psDriver
- The class name of the jdbc driverpsUrl
- The URL of the databasepsUsername
- The username required to access the databasepsPassword
- The password for the above username
-
-
Method Details
-
selectStatementSingleConstraint
public String selectStatementSingleConstraint(String psTablename, String psColumnname, String psConstraint, String psValue) Executes a simple select statement to get back a single column from a single table for a single constraint-value pair If more than one record is returned, this method returns the first record.The following query is executed: SELECT columnname FROM tablename WHERE constraint=value- Parameters:
psTablename
- The name of the table on which the query is madepsColumnname
- The column which is returnedpsConstraint
- The constraint column namepsValue
- The value of the constraint which is to be matched- Returns:
- the first record as string. "norecordfound" if the query returns no records
-
selectStatementDoubleConstraints
public String selectStatementDoubleConstraints(String psTablename, String psColumnname, String psFirstConstraint, String psFirstValue, String psSecondConstraint, String psSecondValue) Executes a simple select statement to get back a single column from a single table for a double constraint-value pair If more than one record is returned, this method returns the first record.The following query is executed: SELECT columnname FROM tablename WHERE firstConstraint=firstValue AND secondConstraint=secondValue- Parameters:
psTablename
- The name of the table on which the query is madepsColumnname
- The column which is returnedpsFirstConstraint
- The first constraint column namepsFirstValue
- The value of the first constraint which is to be matchedpsSecondConstraint
- The second constraint column namepsSecondValue
- The value of the second constraint which is to be matched- Returns:
- the first record as string. "norecordfound" if the query returns no records
-
getRandomRow
public String getRandomRow(String psTablename, String psColumnname, String psConstraint, String psValue) Executes a simple select statement to get back a single column from a single table for a double constraint-value pair If more than one record is returned, this method returns any one of the records at random.Hence the name The following query is executed: SELECT columnname FROM tablename WHERE firstConstraint=firstValue- Parameters:
psTablename
- The name of the table on which the query is madepsColumnname
- The column which is returnedpsConstraint
- The constraint column namepsValue
- The value of the constraint which is to be matched- Returns:
- any random record as string. "norecordfound" if the query returns no records
-
getMaxStringValueFromPatternMatch
public String getMaxStringValueFromPatternMatch(String psTableName, String psColumnName, String psBeforeWildCard, String psAfterWildCard) Retrieves the maximum value within a group of results that match a specified as psBeforeWildCard%psAfterWildCard.- Parameters:
psTableName
- table namepsColumnName
- name of the column being checkedpsBeforeWildCard
- pattern before wildcard(%)psAfterWildCard
- patter after wildcard(%)- Returns:
- string representation of the maximum value
-
main
Main Method- Parameters:
args
-
-