com.konakartadmin.db
Class ExecuteSQL

java.lang.Object
  extended by com.konakartadmin.db.ExecuteSQL

public class ExecuteSQL
extends java.lang.Object

Executes the SQL in the specified input file against the database whose connection details are defined in the specified properties file. It writes output to stdout.


Field Summary
private static int DB2
           
private static boolean debug
           
private static java.lang.String DEFAULT_FILE_ENCODING
           
private static java.lang.String DEFAULT_STORE
           
private static java.lang.String inputEncoding
           
private static int MSSQL
           
private static int MYSQL
           
private static int ORACLE
           
private static int POSTGRE
           
private static java.lang.String usage
           
 
Constructor Summary
ExecuteSQL()
           
 
Method Summary
private static boolean commentLine(java.lang.String line)
           
private static boolean emptyLine(java.lang.String line)
           
static int execute(java.io.File inFile, java.io.File propFile)
          Execute the SQL against the database defined in the properties file.
static int execute(java.io.File inFile, java.io.File propFile, java.lang.String storeId)
          Execute the SQL against the database defined in the properties file.
static int execute(java.io.File inFile, java.io.File propFile, java.lang.String storeId, boolean debugFlag)
          Execute the SQL against the database defined in the properties file.
static int execute(java.io.File inFile, java.io.File propFile, java.lang.String storeId, java.lang.String kkVer)
          Execute the SQL against the database defined in the properties file.
static int execute(java.io.File inFile, java.io.File propFile, java.lang.String storeId, java.lang.String kkVer, boolean debugFlag)
          Execute the SQL against the database defined in the properties file.
static int execute(java.lang.String inFileName, java.lang.String propFileName)
          Execute the SQL against the database defined in the properties file.
static java.lang.String getInputEncoding()
           
private static java.lang.String getNextLine(java.util.Scanner br)
           
private static boolean kkVersionMarker(java.lang.String line, java.lang.String kkVer)
           
static void main(java.lang.String[] args)
           
private static boolean nonSql(java.lang.String line)
           
private static void printSQLFailed()
           
private static java.lang.String removeFinalString(java.lang.String line, java.lang.String ch)
           
static void setInputEncoding(java.lang.String inputEncoding)
           
private static boolean theEnd(java.lang.String line)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

usage

private static final java.lang.String usage
See Also:
Constant Field Values

DEFAULT_STORE

private static final java.lang.String DEFAULT_STORE
See Also:
Constant Field Values

debug

private static boolean debug

DB2

private static final int DB2
See Also:
Constant Field Values

ORACLE

private static final int ORACLE
See Also:
Constant Field Values

POSTGRE

private static final int POSTGRE
See Also:
Constant Field Values

MSSQL

private static final int MSSQL
See Also:
Constant Field Values

MYSQL

private static final int MYSQL
See Also:
Constant Field Values

DEFAULT_FILE_ENCODING

private static java.lang.String DEFAULT_FILE_ENCODING

inputEncoding

private static java.lang.String inputEncoding
Constructor Detail

ExecuteSQL

public ExecuteSQL()
Method Detail

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Parameters:
args -
Throws:
java.lang.Exception

execute

public static int execute(java.lang.String inFileName,
                          java.lang.String propFileName)
Execute the SQL against the database defined in the properties file.

Parameters:
inFileName - the SQL file name to run
propFileName - the Properties file name that defines the database credentials
Returns:
0 for successful execution, otherwise a non-zero integer indicating failure

execute

public static int execute(java.io.File inFile,
                          java.io.File propFile)
Execute the SQL against the database defined in the properties file.

Parameters:
inFile - the SQL file to run
propFile - the Properties file that defines the database credentials
Returns:
0 for successful execution, otherwise a non-zero integer indicating failure

execute

public static int execute(java.io.File inFile,
                          java.io.File propFile,
                          java.lang.String storeId)
Execute the SQL against the database defined in the properties file.

Parameters:
inFile - the SQL file to run
propFile - the Properties file that defines the database credentials
storeId -
Returns:
0 for successful execution, otherwise a non-zero integer indicating failure

execute

public static int execute(java.io.File inFile,
                          java.io.File propFile,
                          java.lang.String storeId,
                          java.lang.String kkVer)
Execute the SQL against the database defined in the properties file.

Parameters:
inFile - the SQL file to run
propFile - the Properties file that defines the database credentials
storeId -
kkVer - execute the SQL up to the specified kkVersion. It stops processing the file if it encounters a line starting with "# vN.N.N.N" or "-- vN.N.N.N". If kkVer is null, no version checking is carried out.
Returns:
0 for successful execution, otherwise a non-zero integer indicating failure

execute

public static int execute(java.io.File inFile,
                          java.io.File propFile,
                          java.lang.String storeId,
                          boolean debugFlag)
Execute the SQL against the database defined in the properties file.

Parameters:
inFile - the SQL file to run
propFile - the Properties file that defines the database credentials
storeId -
debugFlag - debug flag - true to enable debug
Returns:
0 for successful execution, otherwise a non-zero integer indicating failure

execute

public static int execute(java.io.File inFile,
                          java.io.File propFile,
                          java.lang.String storeId,
                          java.lang.String kkVer,
                          boolean debugFlag)
Execute the SQL against the database defined in the properties file.

Parameters:
inFile - the SQL file to run
propFile - the Properties file that defines the database credentials
storeId -
kkVer - execute the SQL up to the specified kkVersion. It stops processing the file if it encounters a line starting with "# vN.N.N.N" or "-- vN.N.N.N". If kkVer is null, no version checking is carried out.
debugFlag - debug flag - true to enable debug
Returns:
0 for successful execution, otherwise a non-zero integer indicating failure

printSQLFailed

private static void printSQLFailed()

commentLine

private static boolean commentLine(java.lang.String line)

emptyLine

private static boolean emptyLine(java.lang.String line)

theEnd

private static boolean theEnd(java.lang.String line)

kkVersionMarker

private static boolean kkVersionMarker(java.lang.String line,
                                       java.lang.String kkVer)

removeFinalString

private static java.lang.String removeFinalString(java.lang.String line,
                                                  java.lang.String ch)

nonSql

private static boolean nonSql(java.lang.String line)

getNextLine

private static java.lang.String getNextLine(java.util.Scanner br)

getInputEncoding

public static java.lang.String getInputEncoding()
Returns:
inputEncoding

setInputEncoding

public static void setInputEncoding(java.lang.String inputEncoding)
Parameters:
inputEncoding -


Copyright © 2011 DS Data Systems UK Ltd.