Skip navigation links

MySQL Forums :: Connector/JDBC and Java :: Connection to mysql using jsp


Advanced Search

Connection to mysql using jsp
Posted by: bindu priyadarshini ()
Date: September 24, 2006 09:39AM

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>

Options: ReplyQuote


Subject Written By Posted
Connection to mysql using jsp arun chanumalla 04/04/2005 10:50AM
Re: Connection to mysql using jsp Sudhir Movva 04/05/2005 01:36PM
Re: Connection to mysql using jsp Megha Bhagat 04/18/2005 03:30AM
Re: Connection to mysql using jsp yenne jagadeesh 11/15/2006 04:20AM
Re: Connection to mysql using jsp Bill Karwin 11/15/2006 10:57AM
connection to mysql using jsp junia phiong 11/27/2005 05:27AM
Connection to mysql using jsp bindu priyadarshini 09/24/2006 09:39AM
Re: Connection to mysql using jsp Bill Karwin 09/24/2006 10:26AM
Connection to mysql using jsp uma maheswari 12/27/2007 11:53PM
Re: Connection to mysql using jsp kuna Ram 12/31/2007 09:54PM
Re: Connection to mysql using jsp sukasom chaiyakul 04/06/2005 05:16AM
Re: Connection to mysql using jsp Ashish Patil 01/21/2006 07:59AM
Re: Connection to mysql using jsp Ashish Patil 01/21/2006 07:42AM
Re: Connection to mysql using jsp Vetri Selvan 02/15/2006 12:12AM
Re: Connection to mysql using jsp Arun Kumar 02/19/2006 11:57PM
Connection to mysql using jsp/jdbc Arun Kumar 02/20/2006 01:46AM
Re: Connection to mysql using jsp/jdbc raj kris 12/14/2007 01:11AM
Connection to mysql using jsp/jdbc Anitha 05/16/2006 05:58AM
Re: Connection to mysql using jsp Antonel Pazargic 02/20/2006 12:20AM
Re: Connection to mysql using jsp mitesh bhimjiyaani 05/17/2006 07:26AM
Re: Connection to mysql using jsp yenne jagadeesh 11/15/2006 04:15AM
Re: Connection to mysql using jsp labhshree kodhe 06/05/2006 12:41AM
Re: Connection to mysql using jsp sourav mukherjee 08/03/2007 06:24AM
Re: Connection to mysql using jsp sekhar babu patnam 08/08/2007 12:44AM
create System DSN in jsp? b g 06/09/2009 04:43AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.