You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Al...@trilogy.com on 2003/07/09 05:24:00 UTC
Two questions (MySQL Pooling and ActionForm)
Hello everyone.
I am new to struts. I have the following two questions:
(1) About MySQL DataSource Pooling: I have set up my struts-config.xml
like the following:
<data-sources>
<data-source>
<set-property property="description" value="Example Data Source
Configuration"/>
<set-property property="driverClass" value="com.mysql.jdbc.Driver"/>
<set-property property="maxCount" value="8"/>
<set-property property="minCount" value="2"/>
<set-property property="url"
value="jdbc:mysql://mysite/408D?autoReconnect=true"/>
<set-property property="user" value="408D"/>
<set-property property="password" value=""/>
<set-property property="autoCommit" value="false"/>
</data-source>
</data-sources>
and I am using "mysql-connector-java-3.0.8-stable-bin.jar" driver. All is
good and I can access my pool but when I leave my application overnight,
the next morning I get an exception, when it wants to use the pool. The
README file coming with the above driver says that the "stale" connections
die after 8 hours and suggested to add the attribute "autoReconnect=true" which I did but am still getting the same result. Does anyone have any
suggestion?
(2) I have an ActionForm which has a checkbox. This checkbox is supposed
to reflect the state of a boolean attribute in a certain database. I have
an "student" instance (of a class Student)which is saved to the session
and student.getStatus() returns the current state. Anyhow, what I want to
do is the following: when I access the JSP page which is associated with
that ActionForm true the form-tag action, I want the checkbox to show the
status based on the student.getStatus(). At the same time, when I toggle
the checkbox, and click on submit, I want the database to be updated. The
problem that I see is that
(a) If I use the reset(...) method of the ActionForm to say something
like:
this.status = ((Student)
request.getSession().getAttribute("student")).getStatus();
then on opening the jsp page for the first time, I get the correct state
for my checkbox but when I toggle that and submit, it doesn't really
accept my new state
(b) On the other hand, if in that reset() method, I simply say:
this.status = false;
then the first time I access the page, it is always unchecked but toggling
that and submitting the form does update the database.
So what is the proper way of doing this? My ActionForm is different from
my "entity" (i.e. "student") since they had many stuff which were not
common between them.
Any help is greatly appreciated.
Thanks,
Ali.
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org