Spring Boot:1.3.2.RELEASE 瓦丁:7.6.3 Mysql:mysql-java-connector-5.1.38 HikariCP:2.4.3
因此,我创建了一个仅包含 id 和名称列的表格。然后是一个vaadin componant Table来显示表的内容。到现在为止一切都很好。然后我尝试用vaadin Filter过滤表,如果连接池是 com.vaadin.data.util.sqlcontainer.connection.SimpleJDBCConnectionPool ,它就可以工作,如果是 com则不行.vaadin.data.util.sqlcontainer.connection.J2EEConnectionPool 我使用HikariCP作为数据源。
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);
}
我选择HikariCP作为数据源的原因是为了获得更好的性能,而且我不确定vaadin连接池是否会比HikariCP更好。或者,它仅限于过滤功能的vaadin连接池?