Interstage Shunsaku Data Manager Application Development Guide - Microsoft(R) Windows(R) 2000/ Microsoft(R) Windows Server(TM) 2003 - - UNIX -
Contents Index PreviousNext

Part 2 Developing Applications by APIs> Chapter 9 Developing Java Applications> 9.3 How to Use Java APIs> 9.3.3 Updating Data

9.3.3.1 Adding Data

Use the prepareInsert method to add data.

The following diagram shows the process for adding data.

[Figure 9-13 Flow of the Process for Adding Data]

mark1Sample Code

ShunConnection con = new ShunConnection();

ShunPreparedStatement pstmt = con.prepareInsert(); (1) // Read data from file FileInputStream oFIS = new FileInputStream("newData.xml"); pstmt.add(oFIS); (2) pstmt.executeInsert(); (3) pstmt.close(); (4)
con.close();

mark2(1) Create a ShunPreparedStatement Object

Use the prepareInsert method to create a ShunPreparedStatement object.

mark2(2) Specify the Data to Add

The following table shows the methods that can be used to add data.

[Table 9-7 Methods that Can be Used to Add Data]

Method

Function

add(String data)

Adds String object data.

add(InputStream data)

Adds InputStream object data.

Multiple items of data can be specified with the add method. Also, data that is stored in multiple files can be added by invoking the add method multiple times. However, a single data item cannot be split into multiple segments and then specified in multiple instances of the add method.

mark2(3) Add the Data

Use the executeInsert method to add the data.

mark2(4) Release the ShunPreparedStatement Object

Use the close method of the ShunPreparedStatement object to release the object when it is no longer required.

mark1Sample Codes for Studio

The following are entry examples available when Studio is used.

Business Class

ShunConnection con = new ShunConnection();
    :
ShunsakuAccessController controller = new ShunsakuAccessController(con);
controller.insert(data);
controller.close();
con.close();

Shunsaku Access Class

public void insert(String data) throws ShunException {
  ShunPreparedStatement pstmti = fConnection.prepareInsert();        (1)
pstmti.add(data);                                                    (2)
pstmti.executeInsert();                                              (3)
pstmti.close();                                                      (4)
}


Contents Index PreviousNext

All Rights Reserved, Copyright(C) FUJITSU LIMITED 2006