XML Databases DOM : XML Database « XML « Java






XML Databases DOM


import java.sql.*;
import java.io.*;
import org.apache.xerces.parsers.*;
import org.w3c.dom.*;
import org.xml.sax.*;

public class XMLDBDOM {

  public static void main(String[] args) throws Exception{

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

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

      conn.setAutoCommit(false);

      Statement s = conn.createStatement();
      s.executeUpdate("CREATE TABLE XMLData(GAMEID INT, MANUAL SERIALIZE(org.w3c.dom.Document))");
      conn.commit();

      File file = new File("XMLData.xml");
      InputStream is = new FileInputStream(file);

      PreparedStatement ps = conn.prepareStatement("INSERT INTO XMLData VALUES(?,?)");

      ps.setInt(1, 1285757);

      DOMParser parser = new DOMParser();
      parser.parse("XMLData.xml");
      Document manual = parser.getDocument();
      ps.setObject(2, manual);

      ps.execute();

      conn.commit();
  }
}


           
       








Related examples in the same category

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