gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 04:16:54 25 4
gpt4 key购买 nike

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

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com