MySQL is the world's most popular open-source database, and there are a lot of Java developers who use MySQL databases in their applications. In the video above, Mark Matthews, architect for Enterprise Tools Team at Sun Microsystems, demonstrated some of the techniques that can help Java developers get more out of their applications that use MySQL.
Mark is a experienced MySQL and Java technologist. Aside from being an architect for MySQL tools at Sun, Mark is the original developer and maintainer of Connector/J, the MySQL JDBC driver.
Mark covered a number of MySQL tips for Java developers including some lesser known configuration options, connection pool settings, and some special MySQL language elements such as ON DUPLICATE KEY UPDATE.
Ref: Java SDN Channel
Links
- Connector/J Source Repository in Launchpad
- MySQL Connector/J Documentation
- Using MySQL With Java
- MySQL Forums
1 comments:
final Properties props = new Properties();
props.put("accessToUnderlyingConnectionAllowed", "true");
props.setProperty("driverClassName", "com.mysql.jdbc.Driver");
StringBuilder options = new StringBuilder();
options.append("cacheServerConfiguration=true");
options.append("&useDynamicCharsetInfo=false");
options.append("&useLocalSessionState=true");
options.append("&alwaysSendSetIsolation=false");
options.append("&rewriteBatchedStatements=true");
props.setProperty("url", "jdbc:mysql://localhost:8040/test?" + options.toString());
props.setProperty("username", "root");
props.setProperty("password", "asdf");
props.setProperty("defaultAutoCommit", false);
props.setProperty("initialSize", "5"
props.setProperty("maxActive", "20");
props.setProperty("minIdle", 2");
props.setProperty("maxIdle", 4");
props.setProperty("maxWait", "30000");
props.setProperty("minEvictableIdleTimeMillis", "15000");
props.setProperty("timeBetweenEvictionRunsMillis", "5000");
// make sure conns are valid
props.setProperty("testWhileIdle, "true");
props.setProperty("validationQuery", "/* ping*/ SELECT 1");
Post a Comment