| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sibvisions.util.db.DBImporter
public class DBImporter
The DBImporter executes DML or DDL statements. The statemens are read from simple text files.
 Use an empty line or a semicolon to separate statements. Use //, # or --
 to comment single lines. A comment line is completly ignored.
 ${VAR1} = select max(id) from table
 
 insert into detail(id, name, table_id) values (1, 'JVx', ${VAR1})
 
 Use custom commands to extend the standard calls:
 
 insert into table(name, creation) values ('JVx', executeTime())
 
 The above command executeTime is mapped to ExecuteTimeCommand.
| Nested Class Summary | |
|---|---|
| protected static class | DBImporter.DBStatementThe DBStatementis a simple POJO that stores the statement (with or without wildcards) and the 
 parameters, if available. | 
| Constructor Summary | |
|---|---|
| DBImporter() | |
| Method Summary | |
|---|---|
| protected  DBImporter.DBStatement | createDBStatement(String pStatement)Creates a statement and parses the parameters. | 
|  boolean | execute(Connection pConnection,
        InputStream pInput)Reads the statements from a stream and executes each statement. | 
|  Exception[] | getExceptions()Gets the last occured exception(s). | 
|  Object | getParameter(String pParameter)Gets the value of a user-defined parameter. | 
|  boolean | isCancelOnFailure()Gets whether the script execution should be stopped if an error occurs. | 
|  boolean | isParameterSet(String pParameter)Gets whether a parameter is set. | 
|  List<DBImporter.DBStatement> | list(InputStream pInput)Gets all statements from the given stream. | 
|  void | setCancelOnFailure(boolean pCancel)Sets whether the complete script should be executed independent of errors. | 
|  void | setParameter(String pParameter,
             Object pValue)Sets a user-defined parameter. | 
| Methods inherited from class java.lang.Object | 
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Constructor Detail | 
|---|
public DBImporter()
| Method Detail | 
|---|
public List<DBImporter.DBStatement> list(InputStream pInput)
                                  throws Exception
pInput - the stream with statements
Exception - if statement parsing fails
public boolean execute(Connection pConnection,
                       InputStream pInput)
                throws Exception
pConnection - the database connectionpInput - the statement stream
true if executions was successful, false if an error occured and setCancelOnFailure(boolean)
         is enabled
Exception - if execution of a statement failed      and setCancelOnFailure(boolean) is disabled
protected DBImporter.DBStatement createDBStatement(String pStatement)
                                            throws Exception
pStatement - the complete statement
Exception - if parameter detection failspublic void setCancelOnFailure(boolean pCancel)
pCancel - true to ignore exceptions during execution, false to throw
                exceptions immediate and stop executiongetExceptions()public boolean isCancelOnFailure()
true if execution is stopped after the first exception, false to
         collect exceptionsgetExceptions()public Exception[] getExceptions()
setCancelOnFailure(boolean)
public void setParameter(String pParameter,
                         Object pValue)
pParameter - the parameter namepValue - the valuepublic Object getParameter(String pParameter)
pParameter - the parameter name
null is possible if the value is not set or the value itself is null.
 isParameterSet(String)public boolean isParameterSet(String pParameter)
null or
 the parameter is not set.
pParameter - the parameter name
true if the parameter is set, false if the parameter is not available| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||