XML Databases and Tools 1: read from clob : XML Database « XML « Java






XML Databases and Tools 1: read from clob


import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class MainClass {

  public static void main(String[] args) {

    try {
      Class.forName("COM.cloudscape.core.JDBCDriver").newInstance();

      Connection conn = DriverManager.getConnection("jdbc:cloudscape:GAMETRADER");

      Statement s = conn.createStatement();

      ResultSet rs = s.executeQuery("SELECT * FROM tableName");

      while (rs.next()) {
        int id = rs.getInt("ID");
        InputStream bis = rs.getAsciiStream("MANUAL");
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        int ch = 0;
        while ((ch = bis.read()) != -1)
          bos.write(ch);
        System.out.println("GAMEID: " + id + "\n" + "MANUAL: " + new String(bos.toByteArray()));
      }

    } catch (Throwable e) {
      System.out.println("exception thrown");
      System.out.println(e);
    }
  }
}



           
       








Related examples in the same category

1.XML Databases and Tools 3
2.XML Databases and Tools 2: read from blob
3.XML Databases DOM