[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Out of memory error with XML and Java ResultSet

  • To: <xml-dev@l...>
  • Subject: Out of memory error with XML and Java ResultSet
  • From: "Brown, Jason B." <Jason.B.Brown@i...>
  • Date: Mon, 8 Sep 2003 10:44:56 -0400
  • Disposition-notification-to: "Brown, Jason B." <Jason.B.Brown@i...>
  • Thread-index: AcN2F8Uutzf7Y8R6R8u4gR0vlg/U4Q==
  • Thread-topic: Out of memory error with XML and Java ResultSet

java out of memory error
Greetings.

I am new to this mailing list.  I was wondering if someone could help me
with a small problem I am having trying to create an XML buffer using
data from a Java ResultSet.  The ResultSet object contains approximately
300,000 rows, which I want to place in a XML buffer.  I managed to
develop an XML implementation that uses JAXP 1.1.  The logic for the
processing is this: I execute the SQL query, obtain the ResultSet, loop
through the result set and as each row in the result set is encountered,
I use getLong methods, etc to get the data and write it to a
StreamResult object.

Here is a code snippet:
			rsMetaData = rs.getMetaData();

			// Provide the System.out object as the output
stream for now
			xmlWrtr = new CisXmlWriterSAX(new
StreamResult(xmlData), 
							((String)
CUtil.getEnv("AdhocDataDtd")));

			numOfColumns = rsMetaData.getColumnCount();

			//
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

			// Start XML document
			xmlWrtr.startXMLDocument();

			// Set root element
			xmlWrtr.addXMLElement("AdhocClaims");

			System.out.println("<<>> Building XML file...");

			while (rs.next()) {
				// Calculate number of rows in result
set
				numOfRows++;
				
				CDebug.print("" + numOfRows);

				// Create the Row parent element (child
element to AdhocClaims element)
				xmlWrtr.addXMLElement("Row");

				for (int colIndex = 1; colIndex <=
numOfColumns; colIndex++) {

				.....
					tempStr =
crossRef.getReadableName(rsMetaData.getColumnName(colIndex));

					// Create the attributes for the
element
					xmlWrtr.addElementAttr("name",
"CDATA", tempStr);

					// Add Column element
					xmlWrtr.addXMLElement("Column");

					// Add the Value element and a
value for the Value element
					xmlWrtr.addElementValue(null,
"");

					// End Column element
					xmlWrtr.endXMLElement("Column");
				}
				.....
			}

			xmlWrtr.endXMLElement("AdhocClaims");
			
			// This is done when finished with adding all
elements within root element
			xmlWrtr.endXMLDocument();
			......

xmlWrtr is a class that contains the following objects:
	private SAXTransformerFactory transFact = null;

	/**
	* Contains where the resulting XML will be placed/contained
	*/
	private StreamResult resultStream = null;
	
	private TransformerHandler handler = null;

	private Transformer serializer = null;

	private AttributesImpl attr = null;

My main goal with this posting is to obtain a memory-friendly solution
for taking information from a Java ResultSet and placing it in a XML
buffer.

Thanks.

Jason B. Brown
CIS IS Claims
215-241-4609
x2-4609 (internal), 11th Floor
mailto:jason.b.brown@i...



CONFIDENTIALITY NOTICE: This E-Mail is intended only 
for the use of the individual or entity to which it is addressed and may contain information that is privileged, confidential and exempt from disclosure under applicable law. If you have received this communication in error, please do not distribute and delete the original message.  Please notify the sender by E-Mail at the address shown. Thank you for your compliance..


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.