Application Server: MySql JDBC Pooling

From Resin 4.0 Wiki

Revision as of 00:00, 22 June 2012 by Ferg (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Share-48.png

Contents

sample configuration

app-inf/mysql.xml

 <cluster xmlns="http://caucho.com/ns/resin">
    <database jndi-name='jdbc/mysql'>
     <driver type="com.mysql.jdbc.Driver">
       <url>jdbc:mysql://localhost:3306/test</url>
       <user>myuser</user>
       <password>mypassword</password>
     </driver>
   </database>
 </cluster>

Injection

import javax.sql.*;
import javax.inject.*:
public class MyServlet extends GenericServlet {
  private @Inject @Named("jdbc/mysql")
  DataSource _myDatabase;
  ...
}

JDBC Mysql Troubleshooting

There is a known problem with the MysqlConnectionPoolDataSource, where the synchronization can cause failures with high traffic. It is recommended to use the com.mysql.jdbc.Driver instead. This problem is verified with Connector/J 5.1.2 and [[1]]

Personal tools
TOOLBOX
LANGUAGES