public class MySQLIf
extends javax.servlet.http.HttpServlet
| Modifier and Type | Field and Description | 
|---|---|
| private DBUserInfo | _userThe _user. | 
| private java.sql.Connection | dbConnectionThe db connection. | 
| protected org.apache.log4j.Logger | loggerThe logger. | 
| private static java.lang.String | PROP_FILEThe Constant PROP_FILE. | 
| private java.lang.String | queryHistoryTblThe query history tbl. | 
| private java.sql.ResultSet | resultSetThe result set. | 
| private java.lang.String | sqlStrThe sql str. | 
| private java.sql.Statement | statementThe statement. | 
| Constructor and Description | 
|---|
| MySQLIf()Instantiates a new blank MySQLIf | 
| MySQLIf(DBUserInfo user)Instantiates a new populated MySQLIf | 
| Modifier and Type | Method and Description | 
|---|---|
| private void | closeConnection(java.sql.Connection conn)Close connection. | 
| private void | connect(DBUserInfo user)Connect. | 
| SQLResult | copyProject(DBUserInfo user,
           int projectId)Copy project. | 
| static java.lang.String | executeScript(java.lang.String dbname,
             java.lang.String dbuser,
             java.lang.String dbpassword,
             java.lang.String scriptpath,
             boolean verbose)execute SQL script - not tested. | 
| void | init()initialize database user configuration using properties file. | 
| static void | main(java.lang.String[] args)The main method. | 
| private java.lang.String | parseQueryType(java.lang.String query)parse query type from query string - INSERT, UPDATE, DELETE. | 
| java.util.ArrayList | parseResultSet(java.sql.ResultSet rs)Parse a result set into a list of lists, where the first list is the
 column headings and the subsequent lists contain the data. | 
| private java.lang.String | parseTableName(java.lang.String query)parse table name from query string. | 
| private boolean | recordQuery(java.lang.String user,
           java.lang.String query)record SQL by inserting query data to a table database connection must
 exist prior!!!!. | 
| SQLResult | runSQL(DBUserInfo user,
      java.lang.String stmt,
      boolean recordFlag)run SQL on MySQL database, return results accordingly. | 
| SQLResult | runSQLArr(DBUserInfo user,
         java.util.List<java.lang.String> sqlList,
         java.lang.Boolean recordFlag)run list of SQLs on MySQL database, return results accordingly. | 
| SQLResult | runSQLArr(DBUserInfo user,
         java.util.List<java.lang.String> sqlList,
         java.lang.Boolean commit,
         java.lang.Boolean recordFlag)run list of SQLs on MySQL database, return results accordingly. | 
| private SQLResult | SQLError(java.sql.SQLException e,
        java.lang.String msg,
        java.lang.String sqlStr)process and construct SQL Error and return. | 
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service, serviceprivate java.sql.Connection dbConnection
private java.sql.Statement statement
private java.sql.ResultSet resultSet
private java.lang.String sqlStr
private static final java.lang.String PROP_FILE
private DBUserInfo _user
private java.lang.String queryHistoryTbl
protected org.apache.log4j.Logger logger
public MySQLIf()
public MySQLIf(DBUserInfo user)
user - the userpublic void init()
init in class javax.servlet.GenericServletprivate void connect(DBUserInfo user) throws java.sql.SQLException
user - the userjava.sql.SQLException - the SQL exceptionpublic SQLResult runSQL(DBUserInfo user, java.lang.String stmt, boolean recordFlag)
user - the userstmt - the stmtrecordFlag - the record flagpublic SQLResult runSQLArr(DBUserInfo user, java.util.List<java.lang.String> sqlList, java.lang.Boolean commit, java.lang.Boolean recordFlag)
user - the usersqlList - the sql listcommit - the commitrecordFlag - the record flagpublic SQLResult runSQLArr(DBUserInfo user, java.util.List<java.lang.String> sqlList, java.lang.Boolean recordFlag)
user - the usersqlList - the sql listrecordFlag - the record flagprivate SQLResult SQLError(java.sql.SQLException e, java.lang.String msg, java.lang.String sqlStr)
e - the emsg - the msgsqlStr - the sql strpublic java.util.ArrayList parseResultSet(java.sql.ResultSet rs)
                                   throws java.sql.SQLException
rs - the rsjava.sql.SQLException - the SQL exceptionprivate boolean recordQuery(java.lang.String user,
                  java.lang.String query)
user - the userquery - the queryprivate java.lang.String parseTableName(java.lang.String query)
query - the queryprivate java.lang.String parseQueryType(java.lang.String query)
query - the querypublic static java.lang.String executeScript(java.lang.String dbname,
                             java.lang.String dbuser,
                             java.lang.String dbpassword,
                             java.lang.String scriptpath,
                             boolean verbose)
dbname - the dbnamedbuser - the dbuserdbpassword - the dbpasswordscriptpath - the scriptpathverbose - the verbosepublic SQLResult copyProject(DBUserInfo user, int projectId)
user - the userprojectId - the project idprivate void closeConnection(java.sql.Connection conn)
conn - the connpublic static void main(java.lang.String[] args)
args - the arguments