i am trying to retreive the contents of the table in my databse into a html form using servlets in tomcat.
here isthe code:

import java.io.*;
import java.lang.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class ServletusingData extends HttpServlet{
	public void doPost(HttpServletRequest request, HttpServletResponse response)
	throws ServletException, IOException{
		PrintWriter pw = response.getWriter();
		String JDBC_DRIVER = "com.mysql.jdbc.Driver";
		String DATABASE_URL = "jdbc:mysql://localhost/mobilepaymentenabler";

		Connection connection;
			Class.forName( JDBC_DRIVER ).newInstance();
			connection = DriverManager.getConnection( DATABASE_URL, "root", "" );
			Statement statement = connection.createStatement(); 
			ResultSet columns = statement.executeQuery( "SELECT * FROM payer"); 
				int payerID = columns.getInt("payerID"); 
				String name = columns.getString("name"); 
				String address = columns.getString("adress");
				int phoneno=columns.getInt("phoneno");
				pw.println("<html> <head><title>Listing The Content of A Database</title></head><body> <p>Content of the payer table:</p> ");
				pw.println("<TR><TD>payerID</TD> <TD>name</TD> <TD>address</TD> <TD>phoneno</TD> </TR>");
				pw.println("<tr><td><%= payerID%></td> <td><%=name%></td> <td><%=address%></td> <td><%=phoneno%></td></tr> ");
				pw.println(" <%}%> </table> </body></html> ");
		}catch (Exception e){

and i am getting the following error:

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

please help!!!

This article has been dead for over six months. Start a new discussion instead.