I'm trying to use a basic mysql jdbc connection but I'm getting HSQLDB errors.
None of the configurations I have indicate that I want to use HSQL.
Error:
org.hsqldb.HsqlException: user lacks privilege or object not found: <(mytable)>
How can I avoid using hsql and stick to mysql
Connection Info:
db.url=jdbc:mysql://<HOST>/<SCHEMA>?autoReconnect=true
db.user=<USER>
db.pwd=<PW>
server.port=8000
applicationContext.xml:
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="${db.url}" />
<property name="username" value="${db.user}" />
<property name="password" value="${db.pwd}" />
<property name="initialSize" value="5" />
<property name="maxActive" value="10" />
<property name="minIdle" value="5"/>
<property name="validationQuery" value="SELECT 1"/>
</bean>
DAO Constructor:
@Repository("myDAO")
public class myDAO implements DAOInterface{
private DataSource dataSource;
private JdbcTemplate jdbcTemplateObject;
@Autowired
public myDAO (DataSource ds) {
this.dataSource = ds;
this.jdbcTemplateObject = new JdbcTemplate(dataSource);
}
Query:
final String sql = "<QUERY>";
List<DataObj> allData = jdbcTemplateObject.query(new PreparedStatementCreator() {
@Override
public PreparedStatement createPreparedStatement(Connection con) throws SQLException {
PreparedStatement ps = con.prepareStatement(sql);
ps.setInt(1, param1);
ps.setString(2,param2);
ps.setInt(3, param3);
ps.setString(4,param4);
ps.setString(5,param5);
return ps;
}
}, new DataMapper());
Spring like to auto-configure datasources.
I needed to set auto-configuration to ignore a number of classes in the application.properties file:
spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration, org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration