473,408 Members | 2,477 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Prepared statement setup incorrectly?

108 100+
Greetings,

After changing all my jsp code to use Prepared statements I have an error in the below code.

The error is as follows:-
org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 12 in the jsp file: /examples/wk465682UpdateFAQ.jsp
Generated servlet error:
Syntax error, insert ";" to complete LocalVariableDeclarationStatement
It doesnt appear related at all, line position isnt anywhere near the Prepared statement but Ive been trhoguh the code plenty of times even printed it out and used a marker pen (everythign appears to end with ';' where needed and the { } are equally numbered)

Can anyone spot the mistake? Maybe its time to take a break ....


Expand|Select|Wrap|Line Numbers
  1. <!-- the % tag below is what is called a scriptlet tag - allows java to be embedded in the jsp -->
  2. <%@ page language="java" contentType="text/html" %>
  3. <%@ page import="java.sql.*" %>
  4. <%@ page import="java.util.*" %>
  5. <HTML>
  6. <HEAD>
  7. <TITLE>Update FAQ</TITLE>
  8. <H3>UPDATE FAQ</H3>
  9. <H4>Greetings, <%= session.getAttribute("theName") %></H4>
  10. <BODY>
  11.  
  12. <% 
  13.  
  14. Connection conn1 = null, conn2 = null;
  15.  
  16. try
  17.     { 
  18.          Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
  19.          conn1 = DriverManager.getConnection("jdbc:odbc:FAQ"); 
  20.     }
  21.         catch (Exception e1)  {System.out.print(e1);}
  22.     {
  23.         try
  24.         {  
  25.             Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
  26.             conn2 = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Access Driver*.mdb)};DBQ=C:/Program  // Files/Apache Software Foundation/Tomcat 6.0/webapps/2008-sem2/wk465682/FAQ.mdb");        
  27.         }
  28.         catch (Exception e2) {System.out.print(e2);}
  29.     }
  30.  
  31. Connection conn;
  32.  
  33. if(conn1 == null) conn = conn2;
  34. else conn = conn1;
  35.  
  36.     String myquery  = "SELECT  category, question, answer, sequence from FAQ Where Id = ?" ;
  37.     PreparedStatement mystatement conn.prepareStatement(myquery);
  38.     mystatement.setInt(1,Integer.parseInt(request.getParameter("Id"))); 
  39.  
  40.     ResultSet rs = mystatement.executeQuery();
  41.  
  42.     if(rs.next())    {
  43.                         String faqCategory=rs.getString(1);
  44.                         String faqQuestion=rs.getString(2);
  45.                         String faqAnswer=rs.getString(3);
  46.                         Int faqSequence = rs.getInt(4);
  47. %>
  48.  
  49.     <FORM ACTION="wk465682updateFAQ2.jsp" METHOD="POST">
  50.     Category: <INPUT TYPE="text" NAME="faqCategory" READONLY="true" SIZE=55 VALUE="<%= faqCategory %>"><BR><BR>
  51.     Question<BR>
  52.     <TEXTAREA NAME="faqQuestion" COLS=100 ROWS=2> <%= faqQuestion %> </TEXTAREA><BR><BR>   
  53.     Answer<BR>
  54.     <TEXTAREA NAME="faqAnswer" COLS=100 ROWS=4> <%= faqAnswer %> </TEXTAREA>
  55.     <INPUT TYPE="Int" VALUE="<%= faqSequence %>"><BR>
  56.     <INPUT TYPE="submit" VALUE="   Update   ">
  57.     <INPUT TYPE="Reset" VALUE="Reset fields">     
  58.     </FORM>
  59. <%
  60.                         }
  61. %>
  62.  
  63. <form method="POST" action="wk465682AdminMenu.jsp" name="conform">
  64. <table border="0" cellpadding="0" cellspacing="0" width="200" align="left">
  65. <td width="50%" colspan="2" align="left">
  66. <input type="submit"  value="Return to Admin Menu" size="16">
  67. </td>
  68. </table>
  69. </form>
  70.  
  71. </BODY>
  72. </HTML>
Mar 14 '08 #1
1 1736
robtyketto
108 100+
Thanks BigDaddyLH !!!!!

I'm getting my head round it all now.

Resolved my problem :-)
Mar 15 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: David.Tymon | last post by:
>Description: MySQL v4.1.0-alpha only allows a client to prepare a maximum of 254 statements. On the 255th mysql_prepare() call, a failure is returned with no information returned by...
8
by: No one | last post by:
I am trying to create a prepared statement in ASP, but am having problems with creating the parameter object. I do the following Set fnParam = peopleUpdate.CreateParameter("@firstname",...
1
by: Tom D | last post by:
I'm rewriting a database interface that our company currently has. Currently it's using the Pear::DB interface, but we found that that was introducing a bit too much overhead. I'm rewriting the...
0
by: Prashanth | last post by:
I am getting this error from BEA DB2 Driver in weblogic console. java.sql.SQLException: CURSOR C02 NOT IN A PREPARED STATE java.sql.SQLException: CURSOR C02 NOT IN A PREPARED STATE We keep...
2
by: Cyril VELTER | last post by:
I'm converting an application to use the V3 protocol features in the 7.4 libpq. As I need to make a design choice regarding the use of prepared statements, I'm wondering what ressources does a...
3
by: birju | last post by:
Hi, I'm running SQL Profiler on an SQL Server 2000 database. I see that one stored procedure gets repeatedly executed having a handle of '1'. This query takes a long time to complete. How do I...
2
by: ojorus | last post by:
Hi! Some questions regarding the mysqli-extension (php5) 1) Prepared statements: If I understand things right, prepared statements will give better performance if you make several similar...
1
by: kaushikm | last post by:
How to access sql server inbuilt functions from java prepared statement ? I have used getdate() of sql in a java prepared statement and am connecting to sqlserver. But it's not working. What to do ?
4
by: TechieGrl | last post by:
Prepared statements are new to me and having to do this with a multi- dimensional array is beyond me. Here is the prepared statement block: // Prepare to insert a record into table1...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.