SQLContainer, Filter and Spring


When I try SQLContainer, Filter and Spring, I cannot get correct data records. Please see my test steps:

  1. Define a datasource in Spring applicationContext.xml:

  <bean id="dataSource" class="org.springframework.jdbc.datasource.SimpleDriverDataSource"> 
    <property name="driverClass" value="com.mysql.jdbc.Driver" />  
    <property name="url" value="jdbc:mysql://localhost:3306/mytest" /> 
    <property name="username" value="root" /> 
    <property name="password" value="root" /> 
  1. Define a vaadin JDBCConnectionPool:
public class SpringConnectionPool implements JDBCConnectionPool {

	private Connection conn;
	public SpringConnectionPool(Connection conn) {
		this.conn = conn;
	public void destroy() {		

	public void releaseConnection(Connection conn) {		

	public Connection reserveConnection() throws SQLException {
		return conn;
  1. Define a SQLContainer:
    	SimpleDriverDataSource bean = (SimpleDriverDataSource) SpringContext.getBean("dataSource");
    	JDBCConnectionPool connectionPool = new SpringConnectionPool(bean.getConnection());
   	TableQuery q1 = new TableQuery(nameTable, connectionPool);
	container = new SQLContainer(q1);
  1. Define a filter:
	container.addContainerFilter(new Like("code", "%21%"));

I can get all records of a table (Step 3), but get no record after add a filter (Step 4).

If the connectionPool is replaced by

    		connectionPool = new SimpleJDBCConnectionPool(
    	        	"jdbc:mysql://localhost:3306/mytest", "root", "root", 2, 5);

both steps 3 and 4 are ok.

Does somenoe know whether filter works with Spring or not?

Isn’t the property name driverClassName instead of driverClass or do I remember wrong?

I am afraid that driverClass is correct. If it is changed to be driverClassName, an exception is reported:

Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'driverClassName' of bean class [org.springframework.jdbc.datasource.SimpleDriverDataSource]
: Bean property 'driverClassName' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
	at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:1024)
	at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:900)
	at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:76)
	at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:59)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1358)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1087)
	... 66 more


If you’re not getting any data, you might want to either configure logging on Level.FINE or add a debug breakpoint in TableQuery class at the point where the query is executed (around line 404) to get the actual query which SQLContainer generates with your filter.

After you have the query string, verify that this query will return some rows by running it directly against your DB. Please post back with your results, especially if the generated query is malformed or if the results differ when it’s executed directly on the DB vs. through SQLContainer.