Chapter 4. Use the embed package

Use the embbed package in my program    

Use the embbed package in DB2 database

 Use the embbed package in my program
   
  You can use our package in your program to execute export operation. We have public the method for execute export operation. The follows method you can used.
      
/**export table data in DB2 database to MS Access(from 97 to 2004) database
 *@param schemaName assign the source data table's schema, null means that table is owned by current user
 *@param tableName assign the source table name
 *@param targetDatabase assign the destination database, in general, you want to export table data to a access database. In fact, you can assign any legal jdbc url no the prefix part(jdbc:access:/), so, c:/tmp/a.mdb,  c:/tmp/xx.zip/b.mdb, ////192.168.10.2/sharedir/aa.mdb, //domain.com:3099/c:/data/bb.mdb all can assigned to this parameter,  more about this information, please see the document
 *@param targetTableName     assign the destination table name which you want to exported to it
 *@param targetConnProps  assign the conntion properties, please split multi properties by ';' ,for example, username=abc;password=abc
 */
 public static void exportTable(String schemaName, String tableName, String targetDatabase, String targetTableName, String targetConnProps)
 
 
/**export SQL query result data to MS Access(from 97 to 2004) database
 *@param query assign the SQL query
 *@param targetDatabase assign the destination database, in general, you want to export table data to a access database, so this parameter name is  targetDatabase, but in fact, you can assign any legal jdbc url no the prefix part(jdbc:access:/), so, c:/tmp/a.mdb,  c:/tmp/xx.zip/b.mdb, ////192.168.10.2/sharedir/aa.mdb, //domain.com:3099/c:/data/bb.mdb all can assigned to this parameter,  more about this information, please see the document
 *@param targetTableName     assign the destination table name which you want to exported to it
 *@param targetConnProps assign the conntion properties, please split multi properties by ';' ,for example, username=abc;password=abc
 */
 public static void exportQuery(String query, String targetDirectory, String targetTableName, String targetConnProps)
 
 
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.DB22Access.exportTable(null,"ATABLE","c:/tmp/a.mdb","BTABLE",null);


com.hxtt.data.export.advance.ConnectionGetter.setConnection(yourConnection);
com.hxtt.data.export.advance.DB22Access.exportQuery("select * from ATABLE A,BTABLE B WHERE A.ID=B.ID","c:/tmp/a.mdb","BTABLE",null);
   
  If you think our product is very good and want contains it to your products, please contact webmaster@hxtt.com for more detail information.
   
   
Use the embbed package in DB2 database
 
 
 

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:/EMBDB22Access_WithDRV.jar','DB22Access')

     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 'DB22Access:com.hxtt.data.export.advance.DB22Access.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.

 

   
   

 


Copyright © 2006 Heng Xing Tian Tai Ltd. of Beijing City | All Rights Reserved. |