Application Server: MySql JDBC Pooling
From Resin 4.0 Wiki
(Difference between revisions)
(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 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") |
Revision as of 00:00, 22 June 2012
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]]