I wrote the following simple program to try
jdbc for the first time.
class jdbctrial{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc
dbc
b";
Connection con = DriverManager.getConnection(url);
ResultSet rs;
Statement stmt = con.createStatement();
rs = stmt.executeQuery("select * from Table");
while(rs.next()){
System.out.println(rs.getString(1)+" "+rs.getInt(2)+" "+rs.getString(3));
}
stmt.close();
con.close();
}
i got the following error statements:
jdbctrial.java:2: <identifier> expected
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
^
jdbctrial.java:12: <identifier> expected
rs = stmt.executeQuery("select * from Table");
^
jdbctrial.java:14: illegal start of type
while(rs.next()){
^
jdbctrial.java:17: <identifier> expected
stmt.close();
^
jdbctrial.java:18: <identifier> expected
con.close();
^
5 errors
please help me out.
arul jose.