Ok, I have to admit, I need help with this!  I have created a class that uses
the Jrun datasource to connect and return a resultset.  Here is the Class, when
and where should I try to close the connection, statement, and resultset?  In
this class or the class calling the getResultSet method?

 Also, what's up with Jrun caching this particular class?  Everytime I make a
change, I have to restart the machine!!

Thank you in advance! This is really frustrating.

import java.io.*;
import java.sql.*;
import javax.sql.*;
import javax.naming.*;
import java.util.*;

public class DbDataSource {

    PrintWriter pw = null;
    ResultSet results = null;

     public ResultSet getResultSet(String sql) {
          Statement statement = null;
          Connection connection = null;
        try {
            // Create an instance of the Context
            Context ctx = new InitialContext();
            // Get the data source from java:comp/env/jdbc/jdbc-datasource-name.
            // You define the JDBC data source name in the JMC.
            DataSource ds = (DataSource)ctx.lookup
("java:comp/env/jdbc/BNWPP_DS");
            // Then continue with your database logic.
            // This example is from an ejbLoad method.
            connection = ds.getConnection();
            try {
                    statement = connection.createStatement();

                   // _context is a bean-level variable that holds the
EntityContex.
                   // It is set by the SetEntityContext method.
                   results = statement.executeQuery(sql);

                   } catch (SQLException eSQL) {
                    pw.println("<br>Error: " + eSQL.getMessage());
                   pw.println("<br>Error: " + eSQL.toString() + "<br>");
                    eSQL.printStackTrace();
                    }

              } catch (Exception e) {
               pw.println("<br>Error: " + e.getMessage());
                  pw.println("<br>Error: " + e.toString() + "<br>");
                  e.printStackTrace();
              }
          return results;
          }
     }

______________________________________________________________________
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to