Well, yes, you can. You're getting the "invalid column name" error because one of the two queries has an invalid column name. (Sometimes it's better to treat the error messages as if they are providing you useful information about what you did wrong...)
In your case I'm guessing that "employeeID" isn't the name of a column in the "attendance" table. If that's the case then you should use the PreparedStatement feature where you can use "?" as a place-holder and then set its value via the setInt or setString method or another one like it.
You might also consider using a "select count(*) ..." query which returns a single record containing the number you want, instead of writing Java code to drag all of the records across the network and then do nothing except count them.
By the way this applies to Java in general, because Java code written for a JSF application is still Java code.
By looking at you code, looks like from employee table you fetch employee data and seach attendance records in attendance table. I would recommend to create join query to get data from employee, attendance tables in single db call. Also you should use "?" when you have PreparedStatement.
for your query, try after changing query as below
"select att_status from attendance where e_id="+employeeId;
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: Can we use two quries using prepared statement in one method