This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
Need Help with XML & ResultSet problem... Urgent Please!!!!!!
sam patel
Ranch Hand
Joined: Jun 13, 2002
Posts: 103
posted
0
Hi, I am sorry I have to cross post this, I have this applet-servlet communication. The servelt does the datbase work and the applet shows the image on the applet side. I was doing the query in the servlet side, but i want to use the XML to do DB work and the querys. First I am searching the DB by policynumber. I wrote this class which is ResultSetToXML which takes the ResultSet and boolean to check if the values are null or not. My problem occurs when it goes in the ResultSetToXML and creates the /******* root = new Element("Pinfo");*********/ I have tried this code in Application and it works fine. I am posting one of my class which has the ResultSet and i am passing this ResultSet in the ResultSetToXML. I am in the begenning stage of the XML. I just want to check if it creates the XML file from this REsultSet. Any help is greatly appreciated. Thanks in advance.
//----------------------------------------------------------// ScanDatabaseAccessor class which is on the Servlet side //----------------------------------------------------------// class ScanDatabaseAccessor implements java.io.Serializable{ private Connection dbConnection; private static InputStream stream; private PreparedStatement searchPolicy; private PreparedStatement searchUnmatchAndPolicy; private PreparedStatement searchImageInfo; private String xFirstName, xLastName, xMiddleName, xSSN, xPolicyNumber, xCompanyCode, xCoverage, xInsuredNo; private java.sql.Date xDOB, xApplicationDate;
//************************************** public ResultSetToXML rstx; //************************************** public ScanDatabaseAccessor(String dbDriver, String dbURL, String userID, String passwd) { String tempStr; // use println statements to send status messages to web server console try { log("ScanDataAccessor init: Start"); log("ScanDataAccessor init: Loading Database Driver: " + dbDriver); Class.forName(dbDriver); log("ScanDataAccessor init: Getting a connection to - " + dbURL); System.out.println("username " +userID); System.out.println("password "+passwd); dbConnection = DriverManager.getConnection(dbURL, userID, passwd); log("ScanDataAccessor init: Preparing searchPolicy"); searchPolicy = dbConnection.prepareStatement("Select * from pinfo where policynumber=?"); log("ScanDataAccessor init: Prepared searchPolicy"); log("ScanDataAccessor init: Preparing searchUnmatchAndPolicy"); tempStr = "Select D.ZOOM100,D.DOCTYPE,D.NEWDOCUMENTCODE,P.PINDEX,P.UINDEX,P.DOCUMENTTYPE,P.PID,"; tempStr = tempStr+"P.IDATE,P.MOVETOINDY,U.USERNAME,P.PAGECOUNT from "; tempStr = tempStr+"(POLICY P INNER JOIN DOCUMENTTYPE D ON D.DOCNUMBER=P.DOCUMENTTYPE)"; tempStr = tempStr+" FULL JOIN USERINFO U ON U.YUSERN=P.ICODENUM WHERE P.PID=? "; tempStr = tempStr+"UNION Select D.ZOOM100,D.DOCTYPE,D.NEWDOCUMENTCODE,P.PINDEX,P.UINDEX,P.DOCUMENTTYPE,"; tempStr = tempStr+"P.PID,P.IDATE,P.MOVETOINDY,U.USERNAME,P.PAGECOUNT from (UNMATCH"; tempStr = tempStr+" P INNER JOIN DOCUMENTTYPE D ON D.DOCNUMBER=P.DOCUMENTTYPE) FULL "; tempStr = tempStr+"JOIN USERINFO U ON U.YUSERN=P.ICODENUM WHERE P.PID=?"; log(tempStr); searchUnmatchAndPolicy = dbConnection.prepareStatement(tempStr); log("ScanDataAccessor init: Prepared searchUnmatchAndPolicy"); log("ScanDataAccessor init: Preparing GETIMAGE_WITH_INDEXTYPE"); searchImageInfo = dbConnection.prepareStatement("Select * from GETIMAGE_WITH_INDEXTYPE(?,?)"); log("ScanDataAccessor init: End"); } catch (Exception e) { cleanUp(); log(e); } } public void destroy() { log("policyDataAccessor: destroy"); cleanUp(); } /** * Simple method for logging messages to console. */ protected void log(Object msg) { System.out.println(msg); } public void cleanUp() { try { log("Closing database connection"); dbConnection.close(); } catch (SQLException e) { log(e); } }
ResultSetToXML class which creates the XML file from the ResultSet //-----------------------------------------------------------------------------// public class ResultSetToXML { public OutputStream out; public Element root; public XMLOutputter outputter; public Document doc;
public ResultSetToXML(ResultSet rs, boolean checkifnull){ try{ String tagname=""; String tagvalue=""; System.out.println("before the root = new Element()"); //-------------------------------------------------------------// //----------This is where it stops. I am not getting any erros but its not---------// //----------doing anything after this code so its not creating XML file.----------// root = new Element("pinfo");
I am sorry I have to cross post this If you are sorry about it you should know not to do it. You obviously read more than one forum, what makes you think the people who might answer your problem don't do the same? This thread is closed. All replies to the one in XML.