Nothing is happening.
Here's how I connect to the database:
public class ConnectionBean implements HttpSessionBindingListener{
private Connection connection;
private Statement statement;
private static final String driver="com.mysql.jdbc.Driver";
private static final String dbURL="jdbc:mysql://localhost:3306/employee?autoReconnect=true";
private static final String login="root";
private static final String password="";
public ConnectionBean(){
try{
Class.forName(driver);
connection=DriverManager.getConnection(dbURL, login, password);
statement=connection.createStatement();
}catch (ClassNotFoundException e){
System.err.println("ConnectionBean: driver unavailable.");
connection=null;
}
catch(SQLException e){
System.err.println("ConnectionBean: driver not loaded.");
connection=null;
}
}
public Connection getConnection(){
return connection;
}
public ResultSet executeQuery(String sql) throws SQLException{
return statement.executeQuery(sql);
}
protected void finalize(){
try{
connection.close();
}catch(SQLException e){
}
}
public void valueBound(HttpSessionBindingEvent event) {
System.err.println("ConnectionBean: in the valueBound method.");
try{
if (connection == null || connection.isClosed()){
connection = DriverManager.getConnection(dbURL,login,password);
statement=connection.createStatement();
}
}catch (SQLException e){
connection =null;
}
}
public void valueUnbound(HttpSessionBindingEvent event) {
try{
connection.close();
}catch(SQLException e){
}finally{
connection = null;
}
}
}
my action
EmployeeSearchService service = new EmployeeSearchService();
ArrayList results2;
SearchForm searchForm = (SearchForm) form;
results2=service.listEmp();
searchForm.setResults(results2);
return mapping.getInputForward();
jsp
<logic

resent name="searchForm" property="results2">
<table>
<logic:iterate id="e" name="employees" >
<tr>
<td><bean:write name="e" property="name" /></td>
<td><bean:write name="e" property="ssn" /></td>
</tr>
</logic:iterate>
</table>
</logic

resent>
EmployeeSearchService
public ArrayList listEmp() throws SQLException{
ArrayList listOfEmployees = new ArrayList();
ConnectionBean cnbean = new ConnectionBean();
String sql="select * from myemploy";
ResultSet rs = cnbean.executeQuery(sql);
while (rs.next()) {
Employee employee = new Employee();
employee.setName(rs.getString("name"));
employee.setSsn(rs.getString("ssn"));
listOfEmployees.add(employee);
//System.out.println(listOfEmployees.add(employee));
}
return listOfEmployees;
}
What am I doing wrong?? I don't even know if its connecting to the DB!