Manikandan Thiagarajan
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.j dbc.Driver ");
con = DriverManager.getConnectio n("jdbc:my sql://loca lhost: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.JasperEx ception: org/aspectj/lang/Signature
org.apache.jasper.servlet. JspServlet Wrapper.ha ndleJspExc eption(Jsp ServletWra pper.java: 510)
org.apache.jasper.servlet. JspServlet Wrapper.se rvice(JspS ervletWrap per.java:3 75)
org.apache.jasper.servlet. JspServlet .serviceJs pFile(JspS ervlet.jav a:314)
org.apache.jasper.servlet. JspServlet .service(J spServlet. java:264)
javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.java: 802)
root cause
javax.servlet.ServletExcep tion: org/aspectj/lang/Signature
org.apache.jasper.runtime. PageContex tImpl.doHa ndlePageEx ception(Pa geContextI mpl.java:8 58)
org.apache.jasper.runtime. PageContex tImpl.hand lePageExce ption(Page ContextImp l.java:791 )
org.apache.jsp.simplejdbc_ jsp._jspSe rvice(org. apache.jsp .simplejdb c_jsp:119)
org.apache.jasper.runtime. HttpJspBas e.service( HttpJspBas e.java:97)
javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.java: 802)
org.apache.jasper.servlet. JspServlet Wrapper.se rvice(JspS ervletWrap per.java:3 32)
org.apache.jasper.servlet. JspServlet .serviceJs pFile(JspS ervlet.jav a:314)
org.apache.jasper.servlet. JspServlet .service(J spServlet. java:264)
javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.java: 802)
root cause
java.lang.NoClassDefFoundE rror: org/aspectj/lang/Signature
java.lang.Class.forName0(N ative Method)
java.lang.Class.forName(Un known Source)
org.apache.jsp.simplejdbc_ jsp._jspSe rvice(org. apache.jsp .simplejdb c_jsp:52)
org.apache.jasper.runtime. HttpJspBas e.service( HttpJspBas e.java:97)
javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.java: 802)
org.apache.jasper.servlet. JspServlet Wrapper.se rvice(JspS ervletWrap per.java:3 32)
org.apache.jasper.servlet. JspServlet .serviceJs pFile(JspS ervlet.jav a:314)
org.apache.jasper.servlet. JspServlet .service(J spServlet. java:264)
javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.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\l ib this directory
could i want to set ant classpath?
<html>
<body>
<%
Connection con = null;
try
{
Class.forName("com.mysql.j
con = DriverManager.getConnectio
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.JasperEx
org.apache.jasper.servlet.
org.apache.jasper.servlet.
org.apache.jasper.servlet.
org.apache.jasper.servlet.
javax.servlet.http.HttpSer
root cause
javax.servlet.ServletExcep
org.apache.jasper.runtime.
org.apache.jasper.runtime.
org.apache.jsp.simplejdbc_
org.apache.jasper.runtime.
javax.servlet.http.HttpSer
org.apache.jasper.servlet.
org.apache.jasper.servlet.
org.apache.jasper.servlet.
javax.servlet.http.HttpSer
root cause
java.lang.NoClassDefFoundE
java.lang.Class.forName0(N
java.lang.Class.forName(Un
org.apache.jsp.simplejdbc_
org.apache.jasper.runtime.
javax.servlet.http.HttpSer
org.apache.jasper.servlet.
org.apache.jasper.servlet.
org.apache.jasper.servlet.
javax.servlet.http.HttpSer
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\l
could i want to set ant classpath?
ASKER
now it dispalys
can not display records.
how could i know counter table structure in javatest database in mysql
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
desc counter;
________
radarsh
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
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.
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
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
ASKER
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
>>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
properly and then try rest of the things.
________
radarsh
ASKER
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
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
ASKER
now i got this exception
i put
%>
</table>
<%
}
catch(Exception d)
{
out.println(d.printStackTr ace());
}
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. JspServlet Wrapper.ha ndleJspExc eption(Jsp ServletWra pper.java: 510)
org.apache.jasper.servlet. JspServlet Wrapper.se rvice(JspS ervletWrap per.java:3 75)
org.apache.jasper.servlet. JspServlet .serviceJs pFile(JspS ervlet.jav a:314)
org.apache.jasper.servlet. JspServlet .service(J spServlet. java:264)
javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.java: 802)
root cause
i put
%>
</table>
<%
}
catch(Exception d)
{
out.println(d.printStackTr
}
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.
org.apache.jasper.servlet.
org.apache.jasper.servlet.
org.apache.jasper.servlet.
javax.servlet.http.HttpSer
root cause
>> out.println(d.printStackTr ace());
Should be either out.println(d.getMessage() );
or d.printStackTrace();
________
radarsh
Should be either out.println(d.getMessage()
or d.printStackTrace();
________
radarsh
ASKER
Access denied for user ''@'localhost' (using password: NO)
now that would give message like this
now that would give message like this
Remove the mysql-connector-java-XXXX-
and just add the mysql-connector-java-XXXX-
the -g jar is a debug version and should not be in your classpath
________
radarsh