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

» JWorld@TW » Servlet/JSP 討論區  

按列印兼容模式列印這個話題 列印話題    把這個話題寄給朋友 寄給朋友   
reply to postflat modego to previous topicgo to next topic
本主題所含的標籤
無標籤
作者 多重條件查詢
j_lo2005





發文: 48
積分: 0
於 2007-12-20 09:34 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
請教先進們,
我嘗試寫一個查詢多重條件程式,但一直出錯試了好幾天,可以幫我看一下錯誤出在哪裡嗎?
程式碼
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
<%@ page contentType="text/html;charset=Big5" import="java.sql.*" %>
<%
  String BatchNo = request.getParameter("BatchNo");
  String MaterialType = request.getParameter("MaterialType");
  String VenderNo = request.getParameter("VenderNo");
//
  Class.forName("oracle.jdbc.driver.OracleDriver");
  Connection con =DriverManager.getConnection("jdbc:oracle:thin:@);
  Statement statement = con.createStatement();
  ResultSet rs =null;
 %>
<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>
<BODY>
<%
//==============================================================================
String   strSQL="Select J.IQR_NO BatchNo,J.ITEM_NO MaterialNo,S.INSPECTION_LOT_NO No,S.PIECES_PER_CASE Qty,S.SAMPLE_QTY Sampling,S.QUANTITY OkQty,S.USAGE_DECISION_CODE Judgement,to_char(J.GR_DATE,'yyyy/mm/dd')  IncomingDate,J.SHELF_LIVE ShelfLive,J.SUPPLIER_NAME SupplierName from JOBS J INNER JOIN SAMPLES S ON J.JOB_ID=S.JOB_ID   ";   
  String   str=null;   
  str=(String)request.getParameters("BatchNo");   
  if   (str!=null){   
        if(isFirst==true){   
            strSQL+="where   J.IQR_NO='"+str+"'   ";   
            isFirst=false;   
        }   
  }   
  str=(String)request.getParameters("MaterialType");   
  if   (str!=null){   
        if(isFirst==true){   
            strSQL+="where J.ITEM_NO='"+str+"'   ";   
            isFirst=false;   
        }else{   
            strSQL+='   and  J.ITEM_NO='"+str+"   ;   
        }   
  }   
  str=(String)request.getParameters("VenderNo");   
  if   (str!=null){   
        if(isFirst==true){   
            strSQL+="where   J.SUPPLIER_REF='"+str+"'   ";   
            isFirst=false;   
        }else{   
            strSQL+='   and   J.SUPPLIER_REF='"+str+"   ;   
        }   
  } 
  ResultSet rs=statement.executeQuery(strSQL);
//==============================================================================
while(rs.next())
{

錯誤訊息如下
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
HTTP Status 500 - 
 
--------------------------------------------------------------------------------
 
type Exception report
 
message 
 
description The server encountered an internal error () that prevented it from fulfilling this request.
 
exception 
 
org.apache.jasper.JasperException: Unable to compile class for JSP: 
 
An error occurred at line: 34 in the jsp file: /05_R_RM.jsp
Invalid character constant
31:             strSQL+="where J.ITEM_NO='"+str+"'   ";   
32:             isFirst=false;   
33:         }else{   
34:             strSQL+='   and  J.ITEM_NO='"+str+"   ;   
35:         }   
36:   }   
37:   str=(String)request.getParameters("VenderNo");   
 
Stacktrace:
  org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:85)
  org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
  org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:435)
  org.apache.jasper.compiler.Compiler.compile(Compiler.java:298)
  org.apache.jasper.compiler.Compiler.compile(Compiler.java:277)
  org.apache.jasper.compiler.Compiler.compile(Compiler.java:265)
  org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
  org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:299)
  org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
  org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
 
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.23 logs.
 
--------------------------------------------------------------------------------
 
Apache Tomcat/5.5.23


reply to postreply to post
話題樹型展開
人氣 標題 作者 字數 發文時間
2945 多重條件查詢 j_lo2005 3736 2007-12-20 09:34
2639 Re:多重條件查詢 donaldknuth 79 2007-12-20 09:39
2649 Re:多重條件查詢 j_lo2005 4445 2007-12-20 10:01
2625 Re:多重條件查詢 donaldknuth 103 2007-12-20 10:08
2613 Re:多重條件查詢 j_lo2005 1417 2007-12-20 10:30
2610 Re:多重條件查詢 ra 112 2007-12-20 10:39
2781 Re:多重條件查詢 j_lo2005 1677 2007-12-20 11:05
» JWorld@TW »  Servlet/JSP 討論區

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