This class is not a servlet. To use the static methods in your JSP, you'd need to import the class or reference it as dbdemo.d_sx_123, not just d_sx_123. But it's hard to tell what's wrong without seeing your JSP.
Derek -----Original Message----- From: Charles Williams [mailto:[EMAIL PROTECTED]] Sent: Thursday, December 20, 2001 8:57 AM To: [EMAIL PROTECTED] Subject: Learning Connection Does this servlet look correct? It compiles ok but my dot.jsp file returns error like "can't find connStatement()". I'm learning while I do this so I can't tell if everything here is good. Also my // comments. - [EMAIL PROTECTED] package dbdemo; // identifies package import java.sql.*; // gets class libraries public class d_sx_123 { // define new class public static Connection getConnection() { // define first method Connection conn = null; // declare reference 'conn' to object of type 'Connection' try { // monitors block, throws exception to catch{ } DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver()); // thin jbdc driver conn = DriverManager.getConnection("site:port:db", "id", "pw"); // port is 1521 // now 'conn' is linked with an object } catch (Exception e) { // only if exception occured conn = null; } return conn; // now method returns 'conn' to calling routine } public static String connStatement() { // define second method Connection conn = getConnection(); // declares 'conn' String value = ""; // declare String try { // monitors block; throws exception to catch(){...} Statement stmnt = conn.createStatement(); // sql statement object ResultSet rs = stmnt.executeQuery("select id from emp"); // sql while (rs.next()) { // loop collects rows value = value + (rs.getInt("id"); // catenates results } rs.close(); stmnt.close(); conn.close(); } catch(SQLException sqle) { // because try failed System.out.println(sqle); } return value; // purpose of second method } } =========================================================================== To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST". Some relevant FAQs on JSP/Servlets can be found at: http://archives.java.sun.com/jsp-interest.html http://java.sun.com/products/jsp/faq.html http://www.esperanto.org.nz/jsp/jspfaq.jsp http://www.jguru.com/faq/index.jsp http://www.jspinsider.com
