日期:2014-05-19  浏览次数:20795 次

一个简单的mysql数据库连接问题
链接代码:
//获取连接
public ConnOracle() {
// TODO Auto-generated constructor stub
try {
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/shoppingbook10_1", "root", "root");
} catch (Exception e) {
// TODO: handle exception
}
}

  用database driver测试是 database connection successfully established。

但是登陆操作进不去。 用oracle是可以的,所以其他代码没有问题



错误:

2012-5-11 15:03:28 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet LoginServlet threw exception
java.lang.ClassNotFoundException: org.aspectj.lang.Signature
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at com.easy.util.ConnOracle.<init>(ConnOracle.java:17)
at com.easy.stu.dao.StuDAO.checkLogin(StuDAO.java:200)
at com.easy.stu.servlet.LoginServlet.service(LoginServlet.java:37)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.easy.filter.StuFilter.doFilter(StuFilter.java:54)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.easy.filter.ChracterFilter.doFilter(ChracterFilter.java:51)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:619)


------解决方案--------------------
不要将获取链接的代码写在构造里面,可以先写个方法,然后再在构造里面调用!
------解决方案--------------------
缺 aspectjrt-1.2.jar
------解决方案--------------------
if(rs != null)
rs.close();


------解决方案--------------------
探讨

if(rs != null)
rs.close();