|
||||||||||
| 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.
It allows simple scripting like:
${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.DBStatement
The DBStatement is 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(java.lang.String pStatement)
Creates a statement and parses the parameters. |
boolean |
execute(java.sql.Connection pConnection,
java.io.InputStream pInput)
Reads the statements from a stream and executes each statement. |
java.lang.Exception[] |
getExceptions()
Gets the last occured exception(s). |
java.lang.String |
getFileEncoding()
Gets the file-encoding charset name. |
java.lang.Object |
getParameter(java.lang.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(java.lang.String pParameter)
Gets whether a parameter is set. |
java.util.List<DBImporter.DBStatement> |
list(java.io.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 |
setFileEncoding(java.lang.String pEncoding)
Sets the file-encoding charset name. |
void |
setParameter(java.lang.String pParameter,
java.lang.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 java.util.List<DBImporter.DBStatement> list(java.io.InputStream pInput)
throws java.lang.Exception
pInput - the stream with statements
java.lang.Exception - if statement parsing fails
public boolean execute(java.sql.Connection pConnection,
java.io.InputStream pInput)
throws java.lang.Exception
pConnection - the database connectionpInput - the statement stream
true if executions was successful, false if an error occured and setCancelOnFailure(boolean)
is enabled
java.lang.Exception - if execution of a statement failed and setCancelOnFailure(boolean) is disabled
protected DBImporter.DBStatement createDBStatement(java.lang.String pStatement)
throws java.lang.Exception
pStatement - the complete statement
java.lang.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 java.lang.Exception[] getExceptions()
setCancelOnFailure(boolean)
public void setParameter(java.lang.String pParameter,
java.lang.Object pValue)
pParameter - the parameter namepValue - the valuepublic java.lang.Object getParameter(java.lang.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(java.lang.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 availablepublic void setFileEncoding(java.lang.String pEncoding)
pEncoding - the charset namepublic java.lang.String getFileEncoding()
null if undefined (= system file encoding)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||