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

Part 3 Other Application Developments> Chapter 12 XML Conversion Function> 12.6 Examples of API Usage

12.6.2 Startup Through to ResultSet Acquisition (CSV File)

The following example shows how data stored in a specified CSV file is obtained as the ResultSet object.
In this example, the first row of the CSV file is not set as the column name.
Also, the CSV file contains lines in which delimiters, quotation marks, or backslashes (\) are entered as data, as shown below.

Lines where delimiters, quotation marks, or backslashes (\) are entered as data

"""",",","\"
// Test program for XMLconverter
//
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import com.fujitsu.xmlconverter.XMLGenerator;
import com.fujitsu.xmlconverter.GeneratorMap;
import com.fujitsu.xmlconverter.DocumentFountain;
import com.fujitsu.xmlconverter.CSVSource;
public class Conv_Test
{
  public static void main(String[] args)
  {
    ResultSet rs = null;
    try
    {
      // Create CSVSource object
      CSVSource csvSource = new CSVSource("source.csv") ;

      csvSource.setCode("SJIS");          //  Code setting
      csvSource.setDelimiter(',');                   //  Delimiter setting
      csvSource.setQuote('\"');                     //  Quotation mark character setting
                                              //  Setting method for entering delimiters, quotation marks, and "\" as data
      csvSource.setFirstRecordToColumn(false);     //  Column name setting ( default )

      // Obtain ResultSet object
      rs = csvSource.getResultSet();    //  Obtain ResultSet
    }
    catch(Exception e)
    {
      e.printStackTrace();
      return;
    }

Contents Index PreviousNext

All Rights Reserved, Copyright(C) FUJITSU LIMITED 2006