|
/**export Text(comma separated,or pipe separated, or tab separated) file data to DB2 database |
*@param sourceUrl |
assign the text file directory location, in fact, you can assign any legal jdbc url not contains the prefix part(jdbc:text:/, or jdbc:csv:/), so, c:/tmp, c:/tmp/xx.zip, ////192.168.10.2/sharedir, //domain.com:3099/c:/data all can assigned to this parameter, more about this information, please see the document. |
*@param sourceTableName |
assign the source table name |
*@param targetSchemaName |
assign the destination schema, it null, export to the current schema |
*@param targetTableName |
assign the destination table name which you want to exported to it |
*@param sourceConnPar |
assign the conntion properties, please split multi properties by ';' ,for example, username=abc;password=abc |
*/ |
|
public static void exportTable(String sourceUrl, String sourceTableName, String targetSchemaName, String targetTableName,String sourceConnPar) |
|
|
/**export SQL query result to DB2 database |
*@param sourceUrl |
assign the text file directory location,in fact, you can assign any legal jdbc url not contains the prefix part(jdbc:text:/, or jdbc:csv:/), so, c:/tmp, c:/tmp/xx.zip, ////192.168.10.2/sharedir, //domain.com:3099/c:/data all can assigned to this parameter, more about this information, please see the document. |
*@param querySQL |
assign the query SQL |
*@param targetSchemaName |
assign the destination schema, it null, export to the current schema |
*@param targetTableName |
assign the destination table name which you want to exported to it |
*@param sourceConnPar |
assign the conntion properties, please split multi properties by ';' ,for example, username=abc;password=abc |
*/ |
|
public static void exportQuery(String sourceUrl, String query, String targetSchemaName, String targetTableName, String sourceConnPar) |
|
|
You just supply a DB2 database connection , and then
call the method. We will release this connection after complete a
export operation for we want to avoid holding a reference to the connection
. So, if you want continue execute other export operation, you should
recall the setConnection method, for example, this code execute two
operations.
com.hxtt.data.export.advance.ConnectionGetter.setConnection(yourConnection);
com.hxtt.data.export.advance.Text2DB2.exportTable("c:/tmp","ATABLE",null,"BTABLE",null);
com.hxtt.data.export.advance.ConnectionGetter.setConnection(yourConnection);
com.hxtt.data.export.advance.Text2DB2.exportQuery("c:/tmp","select * from atable a, btable b where a.id=b.id",null,"BTABLE",null); |
|
|
|
In general , the user who can connect to DB2 database have
most of privilege to load our embed package to DB2 database.
You can use the follows command to load package in
SQL editor. This command will load the java package(which located in c
disk of database server) to DB2 databae.
call sqlj.install_jar('file:c:/EMBText2DB2_WithDRV.jar','Text2DB2')
After have load this package to DB2 database,
you can create a JAVA procedure to execute the export operation, the follows
SQL show how to create a java procedure.
create procedure
exportTable(
in schemaname varchar(200),
in tablename varchar(200),
in targetdirectory varchar(200),
in targettablename varchar(200),
in targetconnpar varchar(200))
external name 'Text2DB2:com.hxtt.data.export.advance.Text2DB2.exportTable'
language java parameter style java
You can create other procedure for the other public method. All public method please see here.
Then you call this procedure like call other procedure to execute export operation.
You can see the faq if errors happen, or contact us by email, or here to submit your question.
|
|
|
|