Chapter 4. Use the embed package

Use the embed package in my program    

Use the embed package in Sybase database

Use the embed 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 Sybase database to Corel Paradox 7.x Table
 *@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 targetDirectory assign the destination directory, in general, you want to export table data to a file.But in fact, you can assign any legal jdbc url not contains the prefix part(jdbc:paradox:/), 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 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 exportTableToParadox7(String schemaName, String tableName, String targetDirectory, String targetTableName, String targetConnProps)
 
 /**export table data to Corel Paradox 8.x Table*/
 public static void exportTableToParadox8(String schemaName, String tableName, String targetDirectory, String targetTableName, String targetConnProps) 
 
 /**export table data to Corel Paradox 9.x Table  */
 public static void exportTableToParadox9(String schemaName, String tableName, String targetDirectory, String targetTableName, String targetConnProps)  
 
 /**export table data to Corel Paradox 10.x Table */
 public static void exportTableToParadox10(String schemaName, String tableName, String targetDirectory, String targetTableName, String targetConnProps)
 
 /**export table data to Corel Paradox 11.x Table  */
 public static void exportTableToParadox11(String schemaName, String tableName, String targetDirectory, String targetTableName,String targetConnProps)
 
 /**export table data to Paradox 3 Table  */
 public static void exportTableToParadox3(String schemaName, String tableName, String targetDirectory, String targetTableName, String targetConnProps)
 
 /**export table data to Paradox 3.5 Table  */
 public static void exportTableToParadox3_5(String schemaName, String tableName, String targetDirectory, String targetTableName, String targetConnProps)
 
 /**export table data to Paradox 4.x Table */
 public static void exportTableToParadox4(String schemaName, String tableName, String targetDirectory,String targetTableName, String targetConnProps)
 
 /**export table data to Paradox 5.x Table */
 public static void exportTableToParadox5(String schemaName, String tableName, String targetDirectory,String targetTableName, String targetConnProps)
 
 
/**export SQL query result to Corel Paradox 7.x Table
 *@param querySql assign the SQL query sentence
 *@param targetDirectory assign the destination directory, in general, you want to export table data to a file, so this parameter name is  targetDirectory, but in fact, you can assign any legal jdbc url not contains the prefix part(jdbc:dbf:/), so, c:/tmp,  c:/tmp/xx.zip, ////192.168.10.2/sharedir 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 for build destination database connectiion, please split multi properties by ';' ,for example, username=abc;password=abc
 */
 public static void exportQueryToParadox7(String querySQL, String targetDirectory, String targetTableName, String targetConnProps)
 
 /**export SQL query result to Corel Paradox 8.x Table*/
 public static void exportQueryToParadox9(String querySQL, String targetDirectory, String targetTableName, String targetConnProps) 
 
 /**export SQL query result to Corel Paradox 9.x Table  */
 public static void exportQueryToFoxpro8(String querySQL, String targetDirectory, String targetTableName, String targetConnProps)  
 
 /**export SQL query result to Corel Paradox 10.x Table */
 public static void exportQueryToParadox10(String querySQL, String targetDirectory, String targetTableName, String targetConnProps)
 
 /**export SQL query result to Corel Paradox 11.x Table  */
 public static void exportQueryToParadox11(String querySQL, String targetDirectory, String targetTableName,String targetConnProps)
 
 /**export SQL query result to Paradox 3 Table  */
 public static void exportQueryToParadox3(String querySQL, String targetDirectory, String targetTableName, String targetConnProps)
 
 /**export SQL query result to Paradox 3.5 Table  */
 public static void exportQueryToParadox3_5(String querySQL, String targetDirectory, String targetTableName, String targetConnProps)
 
 /**export SQL query result to Paradox 4.x Table */
 public static void exportQueryToParadox4(String querySQL, String targetDirectory,String targetTableName, String targetConnProps)
 
 /**export SQL query result to Paradox 5.x Table */
 public static void exportQueryToParadox5(String querySQL, String targetDirectory,String targetTableName, String targetConnProps)
 
 
You should supply a Sybase 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.Sybase2Paradox.exportTableToParadox7(null,"ATABLE","c:/tmp","BTABLE",null);


com.hxtt.data.export.advance.ConnectionGetter.setConnection(yourConnection);
com.hxtt.data.export.advance.Sybase2Paradox.exportQueryToParadox7("select * from ATABLE A,BTABLE B WHERE A.ID=B.ID","c:/tmp","NEWTABLE",null);







   
   
  If you think our product is very good and want contains it to your products, please contact sales@hxtt.com for more detail information.
   
 
Use the embed package in Sybase database
 
 
 

At the first, you should enable java at the Sybase database.

You need do as follows, login as sa, and execute the follows command.

  sp_configure "enable java"

  to view whether te Sybase database have enabled java, if you see 1 in the result, it shows this server have enabled java. or else, you should do the follows steps to enable java.   

  sp_configure "enable java",1

  Then, close and restart the Sybase database server.

 


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

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

  In windows,

 
  instjava -f c:/EMBSybase2Paradox_WithDRV.jar' -SDBServername -Ssa -Dmydb

  In Unix/Linux,

   installjava -f c:/EMBSybase2Paradox_WithDRV.jar' -SDBServername -Ssa -Dmydb


 If errors happened when execute this command , please see the FAQ document.

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

create procedure exportTableToParadox8(
    schemaName varchar(255),
    tableName varchar(255),
    targetDirectory varchar(255),
    targetTableName varchar(255),
    targetConnPar varchar(255) )
    language java parameter style java external name
    'com.hxtt.data.export.advance.Sybase2Paradox.exportTableToParadox8(
    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.

   But in the Adaptive Sybase Enterprise(ASE) database, there are some limit when use the java in the procedure. For example, you can access the file in the java procedure. So, if you want export table data to a file or import data from a file, it will throws a Exception. But you can access the network, so, you can export table data to a remote machine or import data from a remote machine, for example,
   exec exportTableToParadox8 null, 'ATABLE','c:/data/',null,null
will throws a exception.
but,
   exec exportTableToParadox8 null, 'ATABLE','//192.168.1.1:5252/c:/data/',null,null
can work normal if you have bought our HXTT JDBC Driver and started the HXTT server at that machine(192.168.1.1, listenered at port 5252).

  In Sybase Anywhere(9.0.1 or upper), there is a configuration parameter, java_input_output, set it to ON, you can access the file.

   You can see the faq if errors happen, or contact us by email, or here to submit your question.

 

   
   

 

 

   

 

 




Copyright © 2010 Hongxin Technology & Trade Ltd. | All Rights Reserved. |