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.1 Startup Through to ResultSet Acquisition (Database Records)

The following example shows how to connect to a database and obtain all the column data from a specified table as the ResultSet object.

Oracle9i is used as the database in this example. A table must already exist in the database before the operations shown in this example can be performed.

// Test program for XMLconverter
//
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import oracle.jdbc.OracleDriver;
import com.fujitsu.xmlconverter.XMLGenerator;
import com.fujitsu.xmlconverter.GeneratorMap;
import com.fujitsu.xmlconverter.DocumentFountain;

public class Conv_Test
{
  public static void main(String[] args)
  {
    ResultSet rs = null;
    try
    {
      Class.forName("oracle.jdbc.driver.OracleDriver");
      Connection dbcon=null;
      dbcon = DriverManager.getConnection(
                     "jdbc:oracle:thin:@xx.yy.zz.fujitsu.com:1521:DB",
                     "username","password" );
      Statement stmt 
            = dbcon.createStatement( ResultSet.TYPE_SCROLL_SENSITIVE,
                                     ResultSet.CONCUR_UPDATABLE);
      rs = stmt.executeQuery("SELECT * FROM PERSON");
    }
    catch(Exception e)
    {
      e.printStackTrace();
      return;
    }

Contents Index PreviousNext

All Rights Reserved, Copyright(C) FUJITSU LIMITED 2006