Chapter 4. Use the embed package

Use the embbed package in my program    

Use the embbed package in Oracle 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 Oracle database to MS Excel(from 97 to 2004) file
 *@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 targetExcelFile assign the destination file, in general, you want to export table data to a access file, But in fact, you can assign any legal jdbc url no the prefix part(jdbc:excel:/), so, c:/tmp/a.xls,  c:/tmp/xx.zip/b.xls, ////192.168.10.2/sharedir/aa.xls, //domain.com:3099/c:/data/bb.xls all can assigned to this parameter,  more about this information, please see the document
 *@param targetSheetName     assign the destination sheet name in the MS Excel file 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 targetExcelFile, String targetSheetName, String targetConnProps)
 
 
/**export SQL query result to MS Excel (from 97 to 2004) file
 *@param querySQL assign the SQL to execute for export data
 *@param targetExcelFile assign the destination file, in general, you want to export SQL query result to a access file, so this parameter name is  targetExcelFile, but in fact, you can assign any legal jdbc url no the prefix part(jdbc:excel:/), so, c:/tmp/a.xls,  c:/tmp/xx.zip/b.xls, ////192.168.10.2/sharedir/aa.xls, //domain.com:3099/c:/data/bb.xls all can assigned to this parameter,  more about this information, please see the document
 *@param targetSheetName    assign the destination sheet name in MS Excel file 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 querySQL, String targetExcelFile, String targetSheetName, String targetConnProps)
 
 
You should supply a Oracle 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.Oracle2Excel.exportTableToExcel2000(null,"ATABLE","c:/tmp/a.xls","BTABLE",null);


com.hxtt.data.export.advance.ConnectionGetter.setConnection(yourConnection);
com.hxtt.data.export.advance.Oracle2Excel.exportQueryToExcel2000("select * from atable a, btable b where a.id=b.id","c:/tmp/a.xls","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 Oracle database
 
 
  

In general , the user who can connect to Oracle database have most of privilege to load our embed package to Oracle database.

    You can use the follows command to load package in windows command or linux shell.

      loadjava -resolve -synonym -verbose -user username/password@oracleSID EMBOracle2Excel_WithDrv.jar

   If errors happened when execute this command , please see here.

   After have load this package to Oracle database, you can create a JAVA procedure to execute the export operation, the follows SQL show how to create a java procedure.

   procedure exportTable(
    sourceschemaname in varchar2,
    tableorviewname varchar2,
    targetdirectory in varchar2,
    targettablename in varchar2,
    targetconnprops in varchar2
  )
    as language java name 'com.hxtt.data.export.advance.Oracle2Excel.exportTable(
    java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String)';
  

   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. |