Question:
how to debug this error?
2006-10-08 22:24:46 UTC
UserData.java:48: illegal start of type
if ( ! Records ) {
^
UserData.java:97: expected
}
^
2 errors
from belove code
package demo;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.ResultSet;
public class UserData {
String firstname;
String lastname;
int countrycode;
String Dfirstname;
String printrow;
ResultSet Results;
//DB Connection related Variables
static Connection con = null;
Statement st = null;
static String URL;
static String username;
static String password;
static {
try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
URL = "jdbc:mysql://localhost:3306/mbtest1";
username = "root";
password = "secret";
con = DriverManager.getConnection(URL,username,password);
} boolean Records = Results.next();
if ( ! Records ) {
System.out.println("No data returned");
}
try {
do {
DfirstnaSystem.out.println(printrow);
} while Result.next (
Four answers:
Joe_Young
2006-10-09 02:54:05 UTC
anand21 here is your link find out for yourself



http://www.google.co.uk/search?hl=en&q=UserData+java+48+illegal+start+of+type&btnG=Search&meta=
Sudha P
2006-10-11 17:55:23 UTC
Hey i think if u have try, you must have catch.

I think its must . But i am sure that there should not be even a single statement inbetween a try and catch block. I think my answer is right. Check out...
Anand
2006-10-09 06:11:29 UTC
the try block must be immediately followed by a catch or finally statement, put a catch block/finally the problem will be solved.



good luck.
Bryan A
2006-10-09 05:36:45 UTC
looks like the problem started with the line:



static {


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...