-
Notifications
You must be signed in to change notification settings - Fork 5
Cookbook: Connect to Mysql
Paul Houle edited this page Dec 30, 2013
·
2 revisions
If you just use the DriverManager that comes with Spring you don't have connection pooling and the way Spring works that means you open a new database connection every time you run a statement and the performance of that is awful. So we use BoneCP
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.28</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>3.2.6.RELEASE</version>
</dependency>
<dependency>
<groupId>com.jolbox</groupId>
<artifactId>bonecp-spring</artifactId>
<version>0.8.0.RELEASE</version>
</dependency>
<bean id="dataSource" class="com.jolbox.bonecp.BoneCPDataSource">
<property name="driverClass" value="com.mysql.jdbc.Driver" />
<property name="jdbcUrl" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean>
In the file $HOME/.artifactId/local.properties
fill out the following:
jdbc.url=**your url**
jdbc.username=**your username**
jdbc.password=**your password**