此致敬礼!谢谢啊!
哪一种都行,只要能用就ok,因为我只了解一点点,所以嘛,越简单越好。。。。
但我的mySQL一直连接不上,不知道是怎么回事啊??
代码如下:
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>mysql连接数据库</title>
</head>
<body>
<%
Connection con = null;
Statement st = null;
ResultSet rs = null;
String dbuser="root";
String dbpswd="12345";
try {
try{Class.forName("com.mysql.jdbc.Driver").newInstance();}
catch (Exception e) {
out.println("Error1 :"+e.toString());
}
String url ="jdbc:mysql://localhost:3306/jnestore";
Connection conn= DriverManager.getConnection(url,dbuser,dbpswd);
st=conn.createStatement();
String sql="select * from catalog_items";
rs=st.executeQuery(sql);
while(rs.next())
{out.print("ok");}
}catch (Exception e) {
out.println("Error :"+e.toString());
}
finally {
try {
rs.close();
st.close();
con.close();
} catch (Exception ex) {
out.println("Error closing database");
} }%>
</body>
</html>
错误信息为:
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 /rcyjc/mysql.jsp at line 19
16: String dbuser="root";
17: String dbpswd="12345";
18: try {
19: try{Class.forName("com.mysql.jdbc.Driver").newInstance();}
20: catch (Exception e) {
21: out.println("Error1 :"+e.toString());
22: }
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:524)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:417)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause
javax.servlet.ServletException: java.lang.NoClassDefFoundError: org/aspectj/lang/Signature
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:850)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779)
org.apache.jsp.rcyjc.mysql_jsp._jspService(mysql_jsp.java:104)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause
java.lang.NoClassDefFoundError: org/aspectj/lang/Signature
java.lang.Class.forName0(Native Method)
java.lang.Class.forName(Unknown Source)
org.apache.jsp.rcyjc.mysql_jsp._jspService(mysql_jsp.java:72)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.13 logs.