JWorld@TW the best professional Java site in Taiwan
      註冊 | 登入 | 全文檢索 | 排行榜  

» JWorld@TW » Java 新手區  

按列印兼容模式列印這個話題 列印話題    把這個話題寄給朋友 寄給朋友    訂閱主題
reply to postflat modego to previous topicgo to next topic
本主題所含的標籤
無標籤
作者 Background process throws an exception: java.lang.StackOverflowError
Sovina





發文: 3
積分: 0
於 2005-02-10 17:53 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
我有個servlet 想當tomcat 一起動的時候會不停地自己運行...
我的code 如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import java.util.*;
 
public class access_db extends HttpServlet implements Runnable {
    
  Thread x;
  Vector vec = new Vector();
  int k=0;
  
   public void init(ServletConfig config) throws ServletException{
    super.init(config);
    x = new Thread (this);
    x.setPriority(Thread.MIN_PRIORITY);
    x.start();
  }
   
  public void run()
    {
      ResultSet rs = null;
        
      int id=0;
      String Name;
      String Sex;  
       
      try{
         //Load the driver
         Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance(); 
         String str="jdbc:odbc:DRIVER=Microsoft Access Driver (*.mdb);DBQ=C:/db1.mdb"; 
         Connection mycon=DriverManager.getConnection(str);
         Statement state = mycon.createStatement(); 
                 
         String varSQL = "select * from emp";
         rs = state.executeQuery(varSQL);
 
          if (rs.next())
          {
           vec.addElement(rs.getString("emp_id"));
           vec.addElement(rs.getString("name"));
           vec.addElement(rs.getString("sex"));           
          } 
       }
       catch (Exception e){
          k= k+1;
      }
  } 
  
    public void doPost(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException
    {   
      response.setContentType("text/html");
        PrintWriter out = response.getWriter();       
        out.println("<html>");
        out.println("<head>");  
        out.println("</head>");
        out.println("<body>");     
          for (int i=0; i<=vec.size(); i++){
            out.println((String) vec.elementAt(1));
          }
        out.println(k); 
        out.println("</body>");
        out.println("</html>"); 
    } 
    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException {
      doGet(request, response);
    } 
} 

之後在url輸入:http://192.168.49.90:8080/HROnline/access_db
access_db就是以上的code

執行後tomcat throws exception:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
HTTP Status 500 - 
--------------------------------------------------------------------------------
 
type Exception report
 
message 
 
description The server encountered an internal error () that prevented it from fulfilling this request.
 
exception 
 
javax.servlet.ServletException: Servlet execution threw an exception
 
root cause 
 
java.lang.StackOverflowError
 
note The full stack trace of the root cause is available in the Apache Tomcat/5.0.27 logs.
 
--------------------------------------------------------------------------------
Apache Tomcat/5.0.27


請問如何解決?


reply to postreply to post
話題樹型展開
人氣 標題 作者 字數 發文時間
2956 Background process throws an exception: java.lang.StackOverflowError Sovina 2789 2005-02-10 17:53
1807 Re:Background process throws an exception: java.lang.StackOverflowError metavige 224 2005-02-16 12:56
» JWorld@TW »  Java 新手區

reply to postflat modego to previous topicgo to next topic
  已讀文章
  新的文章
  被刪除的文章
Jump to the top of page

JWorld@TW 本站商標資訊

Powered by Powerful JuteForum® Version Jute 1.5.8