mahout-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Karl Eigengrund <>
Subject Usage of MySQL as DataSource with connection pooling
Date Mon, 08 Nov 2010 21:29:19 GMT

I am new to Mahout. I am using it to get recommendations out of my data stored in a MySQL
database. I have started by configuring the DataSource programmatically, and followed the
performace hints in the JavaDoc for MySQLJDBCDataModel. But without connection pooling the
performance is with just 3000 preferences extremely bad.

I am using Tomcat and  I have done the configuration as described here:,
under Using Connector/J with Tomcat

My Web.xml:
    <res-ref-name>jdbc/ MySQLDB</res-ref-name>

In the context.xml I have done the same configuration as described under point
Using Connector/J with Tomcat (see link above)

The usual way for retrieving the DataSource via JNDI doesn’t work for me, since Mahout requires
a MySQLJDBCDataModel. The following cast doesn’t work:

InitialContext ctx = new InitialContext();
dataSource = (MysqlDataSource)ctx.lookup(


java.lang.ClassCastException: org.apache.tomcat.dbcp.dbcp.BasicDataSource cannot be cast to

What is the correct way to retrieve the datasource via JNDI and use pooling?

Thank you.

View raw message