Object | +--com.judoscript.util.TableDump
A dump file stores a part or whole of a database table. Dump files are gzipped. The contents are Java-serialized, which are all of basic data types:
String java.version String java.vm.version String java.class.version String[] column attribute names -- titles for a TableData Object[][] column attributes -- data for a TableData (Object[])+ column values Boolean.FALSEThis class provides methods to read from a dump file.
Its static method dumpTable()
dumps the content of
a relational database table with a WHERE clause into a dump file.
There is also a convenience method, generateLoadScript()
,
that generates JudoScript code to upload the data into a(nother)
database table, based on the meta information of the columns.
Constructor Summary | |
TableDump(String fileName)
Takes a dump file name, opens it and reads in the meta information. |
Method Summary | |
void |
close()
|
static long |
dumpTable(java.sql.Connection con,
String tableName,
String fileName,
String whereClause,
int limit,
int promptSegment)
Dumps whole or part of a database table to a dump file. |
void |
generateLoadScript(PrintWriter pw,
String dumpFileName,
String tableName,
boolean createTable)
Generates a JudoScript program that optionally creates the database table and loads the data into it. |
com.judoscript.util.TableData |
getColumnAttrs()
|
String |
getJavaClassVersion()
|
String |
getJavaVersion()
|
String |
getJavaVmVersion()
|
Object[] |
next()
|
void |
reInit(String fileName)
Closes the current one if open, opens a new file and reads in the meta information. |
Methods inherited from class Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public TableDump(String fileName) throws IOException, ClassNotFoundException
Method Detail |
public void reInit(String fileName) throws IOException, ClassNotFoundException
public void close()
public String getJavaVersion()
public String getJavaVmVersion()
public String getJavaClassVersion()
public com.judoscript.util.TableData getColumnAttrs()
public Object[] next() throws IOException
public void generateLoadScript(PrintWriter pw, String dumpFileName, String tableName, boolean createTable) throws IOException
The generated code includes "connect.judi", which should have these connection
parameters specified as url
, username
and password
.
You may modify the generated script to put in correct connection parameters,
and also the CREATE TABLE statement for the column types.
pw
- The print writer used for the generated script code.dumpFileName
- the dump file name.
Can be null, where tableName.tdmp
is used.tableName
- the database table name; must not be null.createTable
- flag indicating a CREATE TABLE statement need be generated.public static long dumpTable(java.sql.Connection con, String tableName, String fileName, String whereClause, int limit, int promptSegment) throws java.sql.SQLException, IOException
con
- the database connection.tableName
- the database table name. Must not be null.fileName
- the dump file name. If null, default use tableName.tdmp
.whereClause
- the where clause for the internal SELECT statement. Can be null.limit
- if > 0, the maximum number of rows to dump.promptSegment
- if > 0, every so many rows written, a count is displayed
to System.out
as a prompt.