0

Trying to execute the serachpage.jsp which can search out data from database on search id basis. Basically I'm getting an error after the select statement.

Code:

<%

try {
    String value = request.getParameter("Issue_ID");
    int Issue_ID=Integer.parseInt(value);
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/report_tracking","root", "root");
    Statement st = conn.createStatement();
    ResultSet rs = st.executeQuery("select * from issue_creating where Issue_ID='"+Issue_ID+"'");
    if(rs.next()) {         
        rs.getString("Problem_Submit");  
        rs.getString("Problem_Submit"); 
        rs.getString("Problem_Descr"); 
    }

%>

Error:

An error occurred at line: [108] in the generated java file: [D:\mohit\apache-tomcat-7.0.37\work\Catalina\localhost_\org\‌​apache\jsp\serachisue_jsp.java]
Syntax error, insert "Finally" to complete TryStatement
An error occurred at line: [109] in the generated java file: [D:\mohit\apache-tomcat-7.0.37\work\Catalina\localhost_\org\‌​apache\jsp\serachisue_jsp.java]
Syntax error, insert "}" to complete ClassBody

Nisse Engström
  • 4,738
  • 23
  • 27
  • 42
  • please treat it as urgent requirement if anyone can help me out as earliest as possible i'll be very thankful to him/her – Mohit Bhardwaj Apr 08 '13 at 04:49
  • can you add stack trace? – shola Apr 08 '13 at 05:13
  • @shola i dont't have any stack trace will provide the catalina log only because this local desktop application. – Mohit Bhardwaj Apr 08 '13 at 05:21
  • An error occurred at line: [108] in the generated java file: [D:\mohit\apache-tomcat-7.0.37\work\Catalina\localhost\_\org\apache\jsp\serachissue_jsp.java] Syntax error, insert "Finally" to complete TryStatement An error occurred at line: [109] in the generated java file: [D:\mohit\apache-tomcat-7.0.37\work\Catalina\localhost\_\org\apache\jsp\serachissue_jsp.java] Syntax error, insert "}" to complete ClassBody – Mohit Bhardwaj Apr 08 '13 at 05:38
  • hey check below answer you missed closing bracket of try block. – shola Apr 08 '13 at 05:39

1 Answers1

1

} bracket missing for try block:

try { 
    String value = request.getParameter("Issue_ID"); int  Issue_ID = Integer.parseInt(value);
    Class.forName("com.mysql.jdbc.Driver").newInstance(); 
    Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/report_tracking","root", "root"); 
    Statement st = conn.createStatement(); ResultSet rs = st.executeQuery("select * from issue_creating where Issue_ID='"+Issue_ID+"'");     
    if(rs.next()) {
        rs.getString("Problem_Submit");
        rs.getString("Problem_Submit"); 
        rs.getString("Problem_Descr"); 
    }
} 
catch(Exception e) {
   e.printStackTrace();
}
dunck
  • 398
  • 1
  • 5
  • 18
shola
  • 704
  • 4
  • 11
  • Getting the error after run the search.jsp program java.lang.NumberFormatException: null at java.lang.Integer.parseInt(Integer.java:417) at java.lang.Integer.parseInt(Integer.java:499) at org.apache.jsp.serachissue_jsp._jspService(serachissue_jsp.java:83) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432) – Mohit Bhardwaj Apr 08 '13 at 06:29
  • Issue_ID need to pass as request param : url?Issue_ID=100 – shola Apr 08 '13 at 06:36
  • how you passing Issue_ID in request? – shola Apr 08 '13 at 06:54
  • select * from issue_creating where Issue_ID='1'"; – Mohit Bhardwaj Apr 08 '13 at 07:00
  • browser url to invoke this jsp? – shola Apr 08 '13 at 07:01
  • try with localhost:8081/serach.jsp?Issue_ID=1 – shola Apr 08 '13 at 08:39
  • what need to be change in the code part apart from your solution ResultSet rs = st.executeQuery("select * from issue_creating where Issue_ID='"+Issue_ID+"'"); – Mohit Bhardwaj Apr 08 '13 at 09:21
  • In this code where i m executing a mysql select statement condition which can match the user enetered credential from database.if anything need to be change in my program code please let me know. – Mohit Bhardwaj Apr 08 '13 at 09:33
  • hi shola any conclusion for my query reagarding the same set of program. – Mohit Bhardwaj Apr 11 '13 at 05:15