Subject | Tomcat Struts Firebird |
---|---|
Author | John Croft |
Post date | 2002-12-30T17:26:42Z |
Hello -
I am using the RC2 driver with Tomcat 4.1.18 and
Struts 1.0.2 and Firebird 1.0.2. My test application
is a user list where you login and add, edit, and
delete users. Everything in my test application works
initially, however after 60 to 90 minutes of
inactivity the database connection is dropped by
Firebird and then the next time the application is
accessed database exceptions are thrown (apparently
Struts doesn't know the connection is gone) and the
application crashes and must be restarted. I have
included my datasource setting and a code snippet
below. If anyone has a suggestion, it would be
greatly appreciated.
Struts Datasource -
<data-sources>
<data-source>
<set-property property="driverClass"
value="org.firebirdsql.jdbc.FBDriver"/>
<set-property property="url"
value="jdbc:firebirdsql:localhost/3050:/opt/interbase/db/employee.gdb"/>
<set-property property="user" value="SYSDBA"/>
<set-property property="password" value="xxx"/>
</data-source>
</data-sources>
Code from Employee Listing -
ServletContext context = servlet.getServletContext();
DataSource dataSource =
(DataSource)Context.getAttribute(Action.DATA_SOURCE_KEY);
try {
conn = dataSource.getConnection();
stmt = conn.createStatement();
rs = stmt.executeQuery("SELECT e.*,r.*,d.* " +
"FROM EMPLOYEE_TBL e, " +
"ROLE_TBL r, " +
"DEPARTMENT_TBL d WHERE " +
"e.ROLEID = r.ROLEID AND " +
"e.DEPID = d.DEPID;");
while (rs.next()) {
employee = new Employee();
employee.setUsername(rs.getString("username"));
...
employees.add(employee);
}
conn.commit();
rs.close();
stmt.close();
conn.close();
}
TIA -
John Croft
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
I am using the RC2 driver with Tomcat 4.1.18 and
Struts 1.0.2 and Firebird 1.0.2. My test application
is a user list where you login and add, edit, and
delete users. Everything in my test application works
initially, however after 60 to 90 minutes of
inactivity the database connection is dropped by
Firebird and then the next time the application is
accessed database exceptions are thrown (apparently
Struts doesn't know the connection is gone) and the
application crashes and must be restarted. I have
included my datasource setting and a code snippet
below. If anyone has a suggestion, it would be
greatly appreciated.
Struts Datasource -
<data-sources>
<data-source>
<set-property property="driverClass"
value="org.firebirdsql.jdbc.FBDriver"/>
<set-property property="url"
value="jdbc:firebirdsql:localhost/3050:/opt/interbase/db/employee.gdb"/>
<set-property property="user" value="SYSDBA"/>
<set-property property="password" value="xxx"/>
</data-source>
</data-sources>
Code from Employee Listing -
ServletContext context = servlet.getServletContext();
DataSource dataSource =
(DataSource)Context.getAttribute(Action.DATA_SOURCE_KEY);
try {
conn = dataSource.getConnection();
stmt = conn.createStatement();
rs = stmt.executeQuery("SELECT e.*,r.*,d.* " +
"FROM EMPLOYEE_TBL e, " +
"ROLE_TBL r, " +
"DEPARTMENT_TBL d WHERE " +
"e.ROLEID = r.ROLEID AND " +
"e.DEPID = d.DEPID;");
while (rs.next()) {
employee = new Employee();
employee.setUsername(rs.getString("username"));
...
employees.add(employee);
}
conn.commit();
rs.close();
stmt.close();
conn.close();
}
TIA -
John Croft
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com