java - 使用 vaadin 从数据库获取数据并显示在屏幕上

标签 java vaadin7

我已经编写了这段代码,但是当运行时,它显示错误

sql command not properly ended

如何修复它?

数据库UI

public class DatabasetableUI extends UI {

    @Override
    protected void init(VaadinRequest request) {
DatabaseTableScreen screen = new DatabaseTableScreen();
        try {
            JDBCConnectionPool connectionPool = new SimpleJDBCConnectionPool( "oracle.jdbc.driver.OracleDriver", "jdbc:oracle:thin:@usadc-sdbxt21:1521:GFRWMUAT","user", "password");
            screen.populate("case_upload_history", connectionPool);
            } catch (SQLException e) {
                //System.out.println("Application");;
                throw new RuntimeException( e.getMessage());
                } enter code here
        setContent( screen);


        }
}

数据库表屏幕

public class DatabaseTableScreen extends VerticalLayout {private SQLContainer container;
    private Table table;
    public DatabaseTableScreen() {

        setMargin( true); 
        table = new Table();
        table.setPageLength( 10); 
        table.setEditable( true); 
        table.setSizeFull();


    enter code here
        //table.addGeneratedColumn("",new RemoveItemColumnGenerator());
        addComponent(table);

    }
    public void populate( String tableName, JDBCConnectionPool connectionPool) {
         QueryDelegate query = new TableQuery( tableName, connectionPool);
        try { 
             container=new SQLContainer(query);
            table.setContainerDataSource( container); 
        } catch (SQLException e) {
            throw new RuntimeException( e);
        }
    }
}

最佳答案

使用TableQuery构造函数的第三个参数,如下所示:

QueryDelegate query = new TableQuery( tableName, connectionPool, new OracleGenerator());

关于java - 使用 vaadin 从数据库获取数据并显示在屏幕上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33211627/

相关文章:

Vaadin SQLContainer刷新

vaadin - 使用@Push读取和写入cookie

java - 在 Maven 中使用 Java 10 的 Groovy 2.5.3

java - XML 解析器和 xpath 表达式

java - 如何克隆ArrayList并克隆其内容?

java - 尝试加载 Vaadin 类时遇到错误

java - Vaadin 可识别不同应用程序的不同浏览器大小,但设备相同

java - #{facesContext} EL 表达式在运行时未解析

java - 以下 json 的 java 中的 JsonPath 是什么

gwt - 如何本地化用作 vaadin 富文本区域工具提示的文本?