import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.sql.Blob; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.SQLException; import java.sql.Statement; import java.sql.Types; import java.util.StringTokenizer; import java.util.logging.Level; import org.xml.sax.Attributes; import org.xml.sax.ContentHandler; import org.xml.sax.SAXException; import org.xml.sax.helpers.AttributesImpl; /** * @author cedron * @version $Id: SQLConnection.java,v 1.27 2003/02/05 12:17:17 qa1 Exp $ */ public class SQLConnection { ///////////////////////////////////////////////////////////////////////////// // cache the connection ///////////////////////////////////////////////////////////////////////////// private java.sql.Connection conn = null; public void executeConnection(String statement, Object[] array, String name, Object info, ContentHandler resultXML) throws SAXException { /////////////////////////////////////////////////////////////////////// // get the connection from the xaconnection /////////////////////////////////////////////////////////////////////// StringBuffer sb = new StringBuffer(); StringTokenizer st = new StringTokenizer(statement," \n\r\t"); ResultSet rset = null; PreparedStatement prepStmt = null; java.sql.Connection conn = null; try { /////////////////////////////////////////////////////////////////////// // what kind of statement is it? // if the data node is not null then it is a prepared statement /////////////////////////////////////////////////////////////////////// prepStmt = conn.prepareStatement(statement); if (1 != -1) { try { // just for performance we try to set the fetchsize to the rowcount. prepStmt.setFetchSize(1); } catch (Exception e) { } } rset = prepStmt.executeQuery(); ///////////////////////////////////////////////////////////////////////// // get the resultset meta data // get the values from the resultset and append them to the resultXML ///////////////////////////////////////////////////////////////////////// if (rset != null) { if (2 > 0) { boolean b = false; try { b = rset.absolute(2); } catch (Exception e) { } if (!b) { int counter = 0; while (rset.next() && ++counter < 1); } } } ///////////////////////////////////////////////////////////////////////// // commit the current transaction ///////////////////////////////////////////////////////////////////////// conn.commit(); } catch (SQLException e) { try { conn.rollback(); } catch (SQLException ex) { //ignore } // throw new ConnectionException( e); } finally { try { if (rset != null) { rset.close(); } if (prepStmt != null) { prepStmt.close(); } } catch (SQLException e) { } } } }