Link to home
Start Free TrialLog in
Avatar of Manikandan Thiagarajan
Manikandan ThiagarajanFlag for India

asked on

solve this my sql exception in jsp

<%@ page language = "java" import ="java.sql.*" %>
<html>
<body>
<%

Connection con = null;

try
{
       Class.forName("com.mysql.jdbc.Driver");
    con = DriverManager.getConnection("jdbc:mysql://localhost:3306/javatest");

     Statement st = con.createStatement();
     ResultSet rs = st.executeQuery("select * from counter");
%>
     <table border =2>

     <%
     while(rs.next())
     {
     %>
          <tr>
          <td><%= rs.getString(1)%></td>

          <td><%= rs.getString(2)%></td>

          <td><%= rs.getString(3)%></td>

          </tr>

    <%
     }
    %>
    </table>
<%
}
catch(Exception d)
{
   out.println("can not display the records");

}

finally
{
    if(con != null)
    {
        try
        {
            con.close();
        }
        catch(SQLException e)
        {
            out.println("Error closing the connection");
        }
    }
}
%>
</body>
</html>


i got exception for this code


ype Exception report

message

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

exception

org.apache.jasper.JasperException: org/aspectj/lang/Signature
      org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

root cause

javax.servlet.ServletException: org/aspectj/lang/Signature
      org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:858)
      org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
      org.apache.jsp.simplejdbc_jsp._jspService(org.apache.jsp.simplejdbc_jsp:119)
      org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

root cause

java.lang.NoClassDefFoundError: org/aspectj/lang/Signature
      java.lang.Class.forName0(Native Method)
      java.lang.Class.forName(Unknown Source)
      org.apache.jsp.simplejdbc_jsp._jspService(org.apache.jsp.simplejdbc_jsp:52)
      org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

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

i put mysql- jav connector 5.0.0b.jar into C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\ROOT\WEB-INF\lib this directory

could i want to set ant classpath?
Avatar of radarsh
radarsh

Alright stmani,

Remove the mysql-connector-java-XXXX-bin-g.jar from your classpath
and just add the mysql-connector-java-XXXX-bin.jar

the -g jar is a debug version and should not be in your classpath

________
radarsh
Avatar of Manikandan Thiagarajan

ASKER

now it dispalys

can not display records.

how could i know  counter table structure in javatest database in mysql
Open mysql command line and type

desc counter;

________
radarsh
ASKER CERTIFIED SOLUTION
Avatar of radarsh
radarsh

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
if i run through eclipse that shows page can not be displayed.

it would  be run with out  ecclipse.

i create a dynamic webproject is called jdbcjsp.

right click that one add jsp file to that.

when i right clikc jdbcjsp folder and select option run as server.

it shows page can not be displayed.


could i modify workspace in ecllpse.

http://localhost:8090/JDBCJSP THIS URL SHOWS IN ECCLIPSE.

FILE NAME IS JDBC.JSP.

IS IT CORRECT.

HOW COULD I RUN THIS PROGRAM IN ECCLIPSE.



Where did you put your jsp? It should be directly under WebContent folder.
Make sure your server is running.

Hit http://localhost:8090 and see if you get something.

How is it 8090? Did you change the port? By default it will be 8080.

________
radarsh
jsp file is there in webcontentfolder only

>>Hit http://localhost:8090 and see if you get something.

it shows page can not be displayed

>>How is it 8090? Did you change the port? By default it will be 8080.

already i changed the port

That means your server is not started! Make sure you start the server
properly and then try rest of the things.

________
radarsh
how to start the server.
stmani, all this is not relevant to your original question. All you asked was
how to get rid of that exception. And I guess that's solved.

You need to read the tomcat guides for information on how to do things.
http://tomcat.apache.org/tomcat-5.5-doc/index.html

________
radarsh
now i got this exception

i put

    %>
    </table>
<%
}
catch(Exception d)
{
 out.println(d.printStackTrace());

}
 that would causes an exception like this
An error occurred at line: 35 in the jsp file: /simplejdbc.jsp


Generated servlet error:
The method println() in the type PrintStream is not applicable for the arguments (void)


      org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

root cause
>> out.println(d.printStackTrace());

Should be either out.println(d.getMessage());

or d.printStackTrace();


________
radarsh


Access denied for user ''@'localhost' (using password: NO)

now that would give message like this