0

Spring Boot: 1.3.2.RELEASE Vaadin : 7.6.3 Mysql: mysql-java-connector-5.1.38 HikariCP: 2.4.3

So I create a Table with only id and name columns. Then a vaadin componant Table to show the content of table. Until now everything is fine. Then I tried to filter the table with a vaadin Filter, and it works if the connection pool is com.vaadin.data.util.sqlcontainer.connection.SimpleJDBCConnectionPool, and doesnot if it is com.vaadin.data.util.sqlcontainer.connection.J2EEConnectionPool which I use HikariCP as the data source.

DBConfig.java

@Configuration
@EnableTransactionManagement
public class DatabaseConfig {

@Bean
public HikariConfig hikariConfig() {
    HikariConfig config = new HikariConfig();
    config.setDriverClassName("com.mysql.jdbc.Driver");
    config.setJdbcUrl("jdbc:mysql://localhost:3306/test?autoReconnect=true&useSSL=false");
    config.setUsername("root");
    config.setPassword("root");
    config.setMaximumPoolSize(20);
    config.setPoolName("connectionPool");
    return config;
}

@Bean
public DataSource dataSource() {
    HikariDataSource dataSource = new HikariDataSource(hikariConfig());
    return dataSource;
}

ApplicationUI.java

@Autowired
private J2EEConnectionPool connectionPool;

@Override
protected void init(VaadinRequest arg0) {
    TableQuery tq = new TableQuery("medecine", connectionPool);// it does not work if I use HikariCP as the J2EEConnectionPool

JDBCConnectionPool pool = new SimpleJDBCConnectionPool("com.mysql.jdbc.Driver",
                "jdbc:mysql://localhost:3306/test?autoReconnect=true&useSSL=false", "root", "root");
TableQuery tq = new TableQuery("medecine", connectionPool);// it works if I use **SimpleJDBCConnectionPool**.

    container = new SQLContainer(tq);
    table = new Table();
    table.setContainerDataSource(container);
    table.setWidth(100, Unit.PERCENTAGE);
    mainLayout.addComponent(table);

Button addFilter = new Button("filter", new ClickListener() {

        private static final long serialVersionUID = -7071683058766115266L;

        @Override
        public void buttonClick(ClickEvent arg0) {
            Filter filter = new SimpleStringFilter("name", "medecine2", true, false);
            container.addContainerFilter(filter);
        }
    });
mainLayout.addComponent(addFilter);
}

The reason I choose HikariCP as the data source is for a better performance and I'm not sure that the vaadin connection pool will be better than HikariCP. Or, it is limited to vaadin connection pool for the filtering function?

mingzhao.pro
  • 709
  • 1
  • 6
  • 20
  • 1
    What do you mean by *it does not work*. Are you seeing results but they are not filtered? Are you getting an exception? Are you getting a compilation error? Is there something in the logs? – Morfic Feb 22 '16 at 14:42
  • @Morfic I have a table with a full list of conteng from db. What does not work is the filtering. NO exception, no compilation error, everything is "normal", it just cannot return fitered result. The table is always the same one. But I also tried JPAContainer and this one works fine. – mingzhao.pro Feb 22 '16 at 21:06

0 Answers0