connecting to mysql using jsp



hi,
I am trying to connect to database using jsp and mysql.java1.4.0,mysql5.0.
25and tomcat5.0 and copied mysql-connector-java-3.1.8-bin-g.jar into tomcat\
common\lib folder and also in tomcat\webapps.In the webapps i stored my
folder.when irun my code i am getting following error
HTTP Status 500 -

------------------------------------------------------------------------------
--

type Exception report

message

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

exception

javax.servlet.ServletException: org/aspectj/lang/Signature
org.apache.jasper.runtime.PageContextImpl.doHandlePageException
(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException
(PageContextImpl.java:758)
org.apache.jsp.imagecode_jsp._jspService(imagecode_jsp.java:129)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:
298)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)


root cause

java.lang.NoClassDefFoundError: org/aspectj/lang/Signature
java.lang.Class.forName0(Native Method)
java.lang.Class.forName(Class.java:130)
org.apache.jsp.imagecode_jsp._jspService(imagecode_jsp.java:84)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:
298)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)


note The full stack trace of the root cause is available in the Apache
Tomcat/5.0.25 logs.


------------------------------------------------------------------------------
--
this is the code for inserting data;

<html>
<head>
<title>result:</title>
</head>
<body bgcolor=#FFFFFF>

<h1>
<font color=white>
result:
</font>
</h1>


<%@ page info="File uploader"%>
<%@ page import="java.io.*"%>
<%@ page import="java.io.File"%>
<%@ page import="java.util.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.sql.Blob"%>
<%@ page import="java.sql.PreparedStatement"%>
<%@ page import="javax.servlet.*"%>
<%@ page import="javax.servlet.http.*"%>
<%

//initializing database connection
try
{


String driver = "org.gjt.mm.mysql.Driver";
Class.forName(driver).newInstance();


Connection con=null;
ResultSet rst=null;

Statement stmt=null;


String url="jdbc:mysql://localhost:3306/tenminutesoffame?
user=root&password=123456";


con=DriverManager.getConnection(url);
stmt=con.createStatement();


String fname=request.getParameter("fname");
String lname=request.getParameter("lname");
String country=request.getParameter("country");

stmt.executeUpdate("insert into form(fname,lname,country) values('"+fname+"',
'"+lname+"','"+country+"')");


con.close();
}


catch (Exception e) {
//print error message
out.println("<center><font size=5> Error in inserting the
data</font></center>");
out.println("the error is:"+e.toString());

}



%>
</body>
</html>
********************************************************************************
this code to retrive data;

<%@ page import="java.sql.*" %>
<%@ page import="java.io.*" %>
<%@ page import="java.sql.Blob"%>
<%@ page import="java.sql.PreparedStatement"%>
<%@ page import="javax.servlet.*"%>
<%@ page import="javax.servlet.http.*"%>
<%@ page info="File uploader"%>
<%


Connection con=null;
ResultSet rst=null;

Statement stmt=null;
try
{
String driver = "org.gjt.mm.mysql.Driver";
Class.forName(driver).newInstance();


String url="jdbc:mysql://localhost:3306/tenminutesoffame?
user=root&password=123456";


con=DriverManager.getConnection(url);
stmt=con.createStatement();



rst=stmt.executeQuery("select * " + "from form");

while(rst.next())
{



out.println( rst.getString("fname") );
out.println(rst.getString("lname"));
out.println(rst.getString("country"));


}
rst.close();
con.close();
}

catch (Exception e) {
//print error message
out.println("<center><font size=5> Error in inserting the
data</font></center>");
out.println("the error is:"+e.toString());

}

%>

********************************************************************************
this is html code

<html>
<title></title>
<BODY bgColor=lightyellow>

<FORM name=registrationpage2 method=post action="imagecode.jsp">
FIRST NAME:
<INPUT type="text" name="fname" value=" ">

<br>
LAST NAME
<input type="text name="lname" value=" ">
<br>
COUNTRY:
<input type="text name="country" value=" ">
<br>
<input type="button" name=Submit value="Submit">

</body>
</html>

.



Relevant Pages

  • [Microsoft][SQLServer 2000 Driver for JDBC]net dll not initi
    ... when attempting to query the database. ... Also, once the exception ... Successive calls to get a connection from the ... dll not initialized: socket write error ...
    (microsoft.public.sqlserver.jdbcdriver)
  • Re: C# - SQL Server Express Connection Problem
    ... I guess the exception is not caught because it is of a different type ... clause or a catchclause could give your further pointers ... The console application opens the sql database using the following ... "Database Connection Failed"); ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Delphi.net is Beta?
    ... error message come up before you have a chance to do that?) ... I let the wizard build the connection string and after it when it comes to ... I can see the list of tables in the database but if I choose any of them, ... Invalid object name 'SYSINDEXKEYS'. ...
    (borland.public.delphi.non-technical)
  • Re: Accessing mdb file via VB code
    ... but then I encountered the error message "Unable to find ... installable ISAM" when a connection to my database was attempted on another ... Dim strConn As String ... By using UserID and Password in the connection string one is telling Jet ...
    (microsoft.public.vb.general.discussion)
  • Re: Mailmerge using a secure database
    ... Database does not have a long path name. ... When I tried re-opening my mail merge documents I get an error message ... Do you need or want specifically to connect with ODBC? ... likely to run into problems where Word truncates the connection string ...
    (microsoft.public.word.mailmerge.fields)