Home | Previous Page | Next Page   Performing Database Operations > Storing and Retrieving XML Documents >

Inserting Data

You can use the methods in this section to insert XML data into a database column.

The parameters in method declarations in this section have the following meanings:

The following methods parse a file using SAX and convert it to a string. You can then use the string returned by these methods as input to the PreparedStatement.setString() method to insert the data into a database column.

public String XMLtoString(String file, String handler, boolean
   validating,boolean nsa) throws SQLException

public String XMLtoString(String file, String handler) throws
   SQLException

public String XMLtoString(String file) throws SQLException

The following methods parse a file using SAX and convert it to an object of class InputStream. You can then use the InputStream object as input to the PreparedStatement.setAsciiStream(), PreparedStatement.setBinaryStream(), or PreparedStatement.setObject() methods to insert the data into a database column.

public InputStream XMLtoInputStream(String file, String handler,
   boolean validating,boolean nsa) throws SQLException;

public InputStream XMLtoInputStream(String file, String handler)
   throws SQLException;

public InputStream XMLtoInputStream(String file) throws
   SQLException;

For examples of using these methods, see Inserting Data Examples.

If no value is specified, or if handler is set to NULL, the driver uses the default Informix handler.

Important:
The driver truncates any input data that is too large for a column. For example, if you insert the x.xml file into a column of type char (55) instead of a column of type char (255), the driver inserts the truncated file with no errors (the driver throws an SQLWarn exception, however). When the truncated row is selected, the parser throws a SAXParseException because the row contains invalid XML.
Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]