hi .. i am new to jsp coding - i hav created a database using mysql workbench - it is a Graphical Interface to creating databases and tables... but the problem is that i dont know how to access my tables through jsp coding .. where should i put my database .. how should i give the path for connection ... i am using Apache Tomcat server ,... please help ASAP

<%@ page language="java" import="java.sql.*" %>
<%
	String url = "jdbc:mysql://localhost:8080/sudhatrial";
	Connection con = null;
	Statement st = null;
	ResultSet rs= null;
%>
<html>
<head>VIEW STUDENT DETAILS
</head>
<body>
<% 
	Class.forName("com.mysql.jdbc.Driver").newInstance();
	String userName = "root";
	String password = "admin";
	con = DriverManager.getConnection(url, userName, password);
	st=con.createStatement();
	rs=null;
%>

<form name="f1">
<TABLE  id="t1"   border=1 cellspacing=2>
<tr>
<Th> REG NUMBER</Th>
<Th> STUDENT NAME</Th>
<Th> ACCOUNT 1 </Th>
<Th> ACCOUNT 2 </Th>
<Th> ACCOUNT 3 </Th>
<Th> ACCOUNT 4 </Th>
<Th> ACCOUNT 5 </Th>
<Th> ACCOUNT 6 </Th>
<Th> ACCOUNT 7 </Th>
<Th> ACCOUNT 8 </Th>
<Th> ACCOUNT 9 </Th>
<Th> ACCOUNT 10</Th>
<Th> TOTAL AMOUNT</Th>
<Th> PAID STATUS</Th>
<Th> DATE PAID</Th>
<Th> PAYMENT MODE</Th>
</tr>
<%

rs=st.executeQuery("SELECT * FROM sudhatrial.student_master");  
while (rs.next()) 
{
       
%>

<tr> 
<td><%=rs.getString("reg_no")%> &nbsp;</td>
<td><%=rs.getString("student_name")%> &nbsp;</td>
<td><%=rs.getString("acc_1")%>&nbsp; </td>
<td><%=rs.getString("acc_2")%> &nbsp; </td>
<td><%=rs.getString("acc_3")%> &nbsp; </td>
<td><%=rs.getString("acc_4")%> &nbsp; </td>
<td> <%=rs.getString("acc_5")%> &nbsp; </td>
<td><%=rs.getString("acc_6")%> &nbsp; </td>
<td><%=rs.getString("acc_7")%> &nbsp; </td>
<td><%=rs.getString("acc_8")%> &nbsp; </td>
<td><%=rs.getString("acc_9")%> &nbsp; </td>
<td><%=rs.getString("acc_10")%> &nbsp; </td>
<td><%=rs.getString("tot_amt")%> &nbsp; </td>
<td><%=rs.getString("paid_status")%> &nbsp; </td>
<td><%=rs.getString("date_paid")%> &nbsp; </td>
<td><%=rs.getString("payment_mode")%> &nbsp; </td>



</tr>
<%
   
}
 %>
rs.close();
</TABLE>
</form>
<% st.close(); %>
<% con.close(); %>

</body>
</html>

THe error i am gettin is :

HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: An exception occurred processing JSP page /1.jsp at line 15

12: 
13: 
14: <% 
15: Class.forName("com.mysql.jdbc.Driver").newInstance();
16: String userName = "root";
17: String password = "admin";
18: 


Stacktrace:
	org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:401)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause

javax.servlet.ServletException: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
	org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:862)
	org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
	org.apache.jsp._1_jsp._jspService(_1_jsp.java:184)
	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
	org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645)
	org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491)
	org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:128)
	org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:66)
	java.lang.Class.forName0(Native Method)
	java.lang.Class.forName(Unknown Source)
	org.apache.jsp._1_jsp._jspService(_1_jsp.java:70)
	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.29 logs.

Apache Tomcat/6.0.29

hi .. i am new to jsp coding - i hav created a database using mysql workbench - it is a Graphical Interface to creating databases and tables... but the problem is that i dont know how to access my tables through jsp coding .. where should i put my database .. how should i give the path for connection ... i am using Apache Tomcat server ,... please help ASAP

Start a new thread.
Create separate classes with methods for connecting, reading/inserting/updating the database. I propose a different class per database table.
Then write the html code (JSP page) and call those methods.

Also read the tutorial at the top of the JSP forum about MVC Connectivity

Moved to new thread, and as javaAddict suggested you should have look at this tutorial JSP database connectivity according to Model View Controller (MVC) Model 2

PS: Would be nice if you read forum rules specially about keep it organized and not hijacking other people posts or reopening old threads....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.