wood burning stoves 2.0*
The moose likes Servlets and the fly likes Strange compiling problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Strange compiling problem" Watch "Strange compiling problem" New topic

Strange compiling problem

Troy Wang

Joined: Jan 31, 2001
Posts: 6
HI, Everyone:
I got a strange compiling message, please any expert to explain to me why that. Here is my sample code:
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.*;
public class DataRetrieval extends HttpServlet
private static Connection con = null;
private static Statement stmt = null;

public void init(ServletConfig config) throws ServletException
//con = HelperClass.getConnection();

public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException

private String [] TitlePool = new String[10];

private int i = 0;
ResultSet rst=null;
stmt = con.createStatement();
String queryString = "select TestID, SubID, RefID, Indicator, Title from ccTest where SubID='1' ;";
rst = stmt.executeQuery(queryString);
while (rst.next())
SequenceData temp = new SequenceData();
SequenceData[i] = temp;
}catch(Exception ex)


public void doGet(HttpServletRequest req, HttpServletResponse res)throws ServletException, IOException

And I got error message like:
DataRetrieval.java:20: '}' expected.
DataRetrieval.java:22: Statement expected.
private String [] TitlePool = new String[10];
DataRetrieval.java:25: Type expected.
3 errors
I thought my code shouldn't have compiling problem so I can't understand the message.
Many thanks.
Phil Hanna
Ranch Hand

Joined: Apr 05, 2001
Posts: 118
Local variables declared inside a method do not take access modifiers (e.g., "private"). Instead of
private String [] TitlePool = new String[10];
private int i = 0;
just write
String [] TitlePool = new String[10];
int i = 0;

Phil Hanna
Sun Certified Programmer for the Java 2 Platform
Author of :
JSP: The Complete Reference
Instant Java Servlets

Phil Hanna<BR>Sun Certified Programmer for the Java 2 Platform<BR>Author of :<BR><A HREF="http://www.amazon.com/exec/obidos/ASIN/0072127686/electricporkchop/107-3548162-1137317" TARGET=_blank rel="nofollow">JSP: The Complete Reference</A><BR><A HREF="http://www.amazon.com/exec/obidos/ASIN/0072124253/electricporkchop/107-3548162-1137317" TARGET=_blank rel="nofollow">Instant Java Servlets</A>
Consider Paul's rocket mass heater.
subject: Strange compiling problem
Similar Threads
to enter Date in Oracle from Servlets
servlet & type4 driver
problem with urldecoder in doGet mehtod
help required about URLConnection
Servlets example