
enterprise javabean and SQL: SQLException
Hi,
I'm testing out a simple session bean in VisualAge to query a DB2
database. When I use
the following piece of code, the bean executes fine:
public String getStudentList() throws java.rmi.RemoteException {
//query database to get list students
String query = "select * from oslevel.t_samplestudennt";
try {
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(query);
if (rs.next()) {
// return just one first name
String studentFName = rs.getString(3);
return studentFName;
}
else
return null;
}
catch (SQLException e){
return "exception";
}
Quote:
} // end
however, if I change the select statement from above to select just one
field, for example:
"select oslevel.t_samplestudent.studentID from
oslevel.t_samplestudent"
it raises a SQLException. Does anyone know what I'm doing wrong?
Thanks for any help.
TNguyen
Sent via Deja.com http://www.***.com/
Share what you know. Learn what you don't.