You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Michael Mok <mi...@consultech.net.au> on 2001/02/01 02:49:20 UTC

RE: Struts and MySQL

Ted

MySQL does support transaction (check out this article
http://www.mysql.com/news/article-54.html ).

You will need to set your table type to "BDB" to enable transaction support.
I am using mm.mysql JDBC driver version 2.0.3 which is JDBC 2.0 driver and
it is quite stable. I would recommend that you to upgrade to this version of
the JDBC driver.

Regards,

Michael Mok
-----Original Message-----
From: Ted Husted [mailto:news.ted@husted.com]
Sent: Thursday, 1 February 2001 9:10
To: Struts List; Struts List
Subject: Re: Struts and MySQL

I've been using MySQL locally on Tomcat and Resin for some time without
any problem.

MySQL doesn't support transactions, so I have to keep autocommit off.

>  (driver "mm.mysql.jdbc-1.2c" => class "org.gjt.mm.mysql.Driver")

I'm not sure what you are saying here. I have a recent mm-mysql.jar on
my classpath, and then use this datasource config, but that's it.

 <data-sources>
  <data-source
     autoCommit="true"
    description="wxxi-gavel"
    driverClass="org.gjt.mm.mysql.Driver"
       maxCount="4"
       minCount="2"
       password=""
            url="jdbc:mysql://localhost/test"
           user="admin"
  />
  </data-sources>


*********** REPLY SEPARATOR  ***********

On 1/31/2001 at 1:11 PM Matthias Bauer wrote:

Hi all,

I tried to use struts with MySQL (driver "mm.mysql.jdbc-1.2c" => class
"org.gjt.mm.mysql.Driver") and ran into an Exception each time I tried
to start
Tomcat:

> Exception in thread "main" java.lang.AbstractMethodError
>         at
org.apache.struts.util.GenericConnection.<init>(GenericConnection.java:1
18)
>         at
org.apache.struts.util.GenericDataSource.createConnection(GenericDataSou
rce.java:623)
>         at
org.apache.struts.util.GenericDataSource.open(GenericDataSource.java:561
)
>         at
org.apache.struts.action.ActionServlet.initDataSources(ActionServlet.jav
a:998)
>         at
org.apache.struts.action.ActionServlet.init(ActionServlet.java:444)
>         at javax.servlet.GenericServlet.init(GenericServlet.java:258)
>         at
org.apache.tomcat.core.ServletWrapper.doInit(ServletWrapper.java:317)
>         at org.apache.tomcat.core.Handler.init(Handler.java:215)
>         at
org.apache.tomcat.core.ServletWrapper.init(ServletWrapper.java:296)
>         at
org.apache.tomcat.context.LoadOnStartupInterceptor.contextInit(LoadOnSta
rtupInterceptor.java:130)
>         at
org.apache.tomcat.core.ContextManager.initContext(ContextManager.java:49
1)
>         at
org.apache.tomcat.core.ContextManager.init(ContextManager.java:453)
>         at org.apache.tomcat.startup.Tomcat.execute(Tomcat.java:195)
>         at org.apache.tomcat.startup.Tomcat.main(Tomcat.java:235)

Digging into the GenericConnection class code teached me the following:
The
mysql driver's Connection.getTypeMap() method throws an
AbstractMethodError
exception when called in:

>    public GenericConnection(GenericDataSource source, Connection
conn,
>                             boolean autoCommit, boolean readOnly)
>        throws SQLException {

at this location:

>         try {
>             this.map = conn.getTypeMap();
>         } catch (SQLException e) {
>             ;   // PostgreSQL throws a "not yet implemented"
exception
>         } catch (UnsupportedOperationException e) {
>             ;   // JDBC-ODBC bridge throws this
>         }


So I changed the catch statements in order to fix it for me.

>         try {
>             this.map = conn.getTypeMap();
>         } catch (SQLException e) {
>             ;   // PostgreSQL throws a "not yet implemented"
exception
>         } catch (UnsupportedOperationException e) {
>             ;   // JDBC-ODBC bridge throws this
>         } catch (AbstractMethodError e) {
>             ;  // mm.mysql driver throws this one
>               }

I think it would make sense to include this little change in the
official struts
code. What do you developers think? If would be happy if someone could
make this
change.

Thanks,

--- Matthias


Matthias Bauer +++ mba@livinglogic.de +++ LivingLogic AG +++
www.livinglogic.de



-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel 716 425-0252; Fax 716 223-2506.
-- http://www.husted.com/about/struts/