hi,
i am having simplest of Servlet program (DBServlet.java) which is trying to
connect to my ORCL DB.
My Application and DB Server are on different machines. I am having my JDBC
Drivers (in ZIP format) on my App Server installed with CLASSPATH.
when I try to run i get below errors:
# java DBServlet
Exception in thread "main" java.lang.NoSuchMethodError: main
#
import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class DBServlet extends HttpServlet {
private Connection con;
private PrintWriter out;
private String url = "jdbc:oracle:thin:@MY_IP_ADDRESS:1521:MY_SID";
public void init(ServletConfig conf)
throws ServletException {
super.init(conf);
try{
//Class.forName("oracle.jdbc.OracleDriver");
//con =DriverManager.getConnection(url, "scott", "tiger");
}catch(Exception e) {
System.err.println(e);
}
}
public void service(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
res.setContentType("text/html");
try {
out = res.getWriter();
out.println("<html>");
out.println("<head>");
out.println("<title> Sample JDBC Servlet Demo" + "</title>");
out.println("</head>");
out.println("<body>");
Class.forName("oracle.jdbc.OracleDriver");
con =DriverManager.getConnection(url, "scott", "tiger");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select * from emp");
out.println("<UL>");
while(rs.next()) {
out.println("<LI>" + rs.getString("EName"));
}
out.println("</UL>");
rs.close();
stmt.close();
} catch(Exception e) { System.err.println(e); }
out.println("</body>");
out.println("</html>");
out.close();
}
_________________________________________________________________
Join the world�s largest e-mail service with MSN Hotmail.
http://www.hotmail.com
===========================================================================
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