Application Server: MySql JDBC Pooling

From Resin 4.0 Wiki

(Difference between revisions)
Jump to: navigation, search
(Created page with "{{Integration}} == sample configuration == === app-inf/mysql.xml === <cluster xmlns="http://caucho.com/ns/resin"> <database jndi-name='jdbc/mysql'> <driver typ...")
 
 
Line 13: Line 13:
 
       </driver>
 
       </driver>
 
     </database>
 
     </database>
 
+
 
 
   </cluster>
 
   </cluster>
  
Line 20: Line 20:
 
  import javax.sql.*;
 
  import javax.sql.*;
 
  import javax.inject.*:
 
  import javax.inject.*:
 
+
 
 
  public class MyServlet extends GenericServlet {
 
  public class MyServlet extends GenericServlet {
 
   private @Inject @Named("jdbc/mysql")
 
   private @Inject @Named("jdbc/mysql")

Latest revision as of 00:00, 22 June 2012

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