This example shows how to export a table in your Java application using Loader commands.
You proceed as follows:
You call the Loader from your Java application.
You connect to the Loader.
You log on to the database.
You export the table using a Loader command.
You end the connection to the Loader.
The individual steps are listed in the comments in the example.
Syntax
import com.sap.dbtech.powertoys.*; import com.sap.dbtech.rte.comm.RTEException; import java.util.Properties; public class LoaderDemo { public LoaderDemo () { } public static void main(String[] args) { // Loader mLoaderSession = null; Loader mLoaderSession; try { // You connect to the Loader. mLoaderSession = Loader.dbLoader(zero,zero); } catch (RTEException rteExc) { System.out.println ("connect failed: " + rteExc.toString ()); return; } try { // You log on as the database user MONA // with the password RED // to the database DEMODB. // see com.sap.dbtech.powertoys.Loader.cmd Method mLoaderSession.cmd ("use serverdb DEMODB"); mLoaderSession.cmd ("use user MONA RED"); // You export the LOADERTEST table // using the cmd method // and the Loader command EXPORT TABLE // see EXPORT TABLE command String result = mLoaderSession.cmd ("EXPORT TABLE HOTEL.CITY DATA OUTSTREAM FILE 'CITY.data'"); System.out.println(result); } catch (RTEException rteExc) { System.out.println ("connection broken: " + rteExc.toString ()); } catch (LoaderException LoaderExc) { System.out.println ("command failed: " + LoaderExc.toString ()); } finally { try { // You end the connection to the Loader. // see com.sap.dbtech.powertoys.Loader.release Method mLoaderSession.release (); } catch (RTEException rteExc) { // ignore } } } }