servlet&tomcat连接oracle 时候tomcat 上老提示以下异常:  严重:the web application [/test] registered the JDBC driver [oracle.jdbc.driver.OracleDriver] but faild to unregist it when the web application was stopped.
To prevent amemory leak,the JDBC Driver has ben forcibly unregistered .
java.sql.SQLException: ORA-00942: 表或视图不存在 关于以上两点很疑惑,具体什么原因呢?1。我程序里面都将相关连接关闭了,怎么还提示那什么严重的信息。
                                     2。表是我刚创建的,也提交了。提示不存在。
以下是我的java代码(import 部分省略了),请大家帮我看看哪里出了问题,谢谢啦!public class ShowRs extends HttpServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
Connection conn = null ;
Statement stmt = null ;
ResultSet rs = null ;

response.setContentType("text/html") ;
response.setCharacterEncoding("gb2312") ;
PrintWriter out = response.getWriter() ;

out.println("<table border=1>") ;
out.println("<tr><td colspan=2 align='center'>Content</td></tr>") ;
try {
Class.forName("oracle.jdbc.driver.OracleDriver") ;
conn = DriverManager.getConnection("jdbc:oracle:thin:@169.254.66.140:1521:orcl", "scott", "tiger") ;
stmt = conn.createStatement() ;
rs = stmt.executeQuery("select * from article") ;
while(rs.next()){
out.println("<tr>") ;
out.println("<td>"+rs.getString("name")+"</td>") ;
out.println("<td>"+rs.getInt("page")+"</td>") ;
out.println("</tr>") ;
}
out.println("<table>") ;
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
} finally{
try{
if(rs != null){
rs.close();
rs = null ;
}
if(stmt != null){
stmt.close() ;
stmt = null ;
}
if(conn != null){
conn.close() ;
conn = null ;
}
out.close() ;
}catch(Exception e){
e.printStackTrace() ;
}
}
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
doGet(req, resp);
}
}

解决方案 »

  1.   

    To prevent amemory leak,the JDBC Driver has ben forcibly unregistered .很明显,JDBC驱动为了防止内存泄漏,不允许卸载驱动。
      

  2.   

    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:111)
    这个出错了,这个地方该怎么写啊??
      

  3.   

    看一下这个网址http://stackoverflow.com/questions/3320400/jdbc-driver-unregisted-when-the-web-application-stops可能是Tomcat版本的问题 换个试试看
      

  4.   

    我oracle是10g的,比较老,tomcat和JDK是前几天才下的最新版本,是不是新老搭配不起来?我去下个新点的mysql试试。
      

  5.   

    请问 囧xiaoye先生or lady,       http://stackoverflow.com/questions/3320400/jdbc-driver-unregisted-when-the-web-application-stops 中 BasicDataSource 和URL指的是哪个?可否就我写的那个类举例说明下?我弄了很久没弄明白。谢谢!public class XBasicDataSource extends BasicDataSource {
        @Override
        public synchronized void close() throws SQLException {
            DriverManager.deregisterDriver(DriverManager.getDriver(url));
            super.close();
        }
    }
      

  6.   

    换了个版本的 tomcat 报告内存泄漏的异常已经消失,但是现在老报告表或视图不存在。
    java.sql.SQLException:ORA-00942:表或视图不存在
      at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:111)
    应该是我这段代码有问题,或者是连接JDBC代码有误,请高手指点下代码该如何写:protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    Connection conn = null ;
    Statement stmt = null ;
    ResultSet rs = null ;

    response.setContentType("text/html") ;
    response.setCharacterEncoding("gb2312") ;
    PrintWriter out = response.getWriter() ;

    out.println("<table border=1>") ;
    out.println("<tr><td colspan=2 align='center'>Content</td></tr>") ;
    try {
    Class.forName("oracle.jdbc.driver.OracleDriver") ;
    conn = DriverManager.getConnection  ("jdbc:oracle:thin:@127.0.0.1:1521:orcl","scott","tiger") ;
    stmt = conn.createStatement() ;
    rs = stmt.executeQuery("select * from article") ;
      

  7.   

    汗啊,弄了整整一晚上了。终于弄出来了。估计是以前oracle里面改变了一些权限的问题,现在里面的表的可见性很混乱。太混乱了~~~