我想从数据库表中提取数据并从 in 中显示到表中JTable
。
这是一些代码,我想将数据库库中的数据添加到数组dataValues [] []
中,我将值存储在dataValues [][]
静态中,但我想将值存储在dataValues[][]
数据库表中。
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Connection connection = DriverManager.getConnection(url, username, password);
Statement statement = connection.createStatement();
String query = "select command_name, omc_name, to_module, start_time, end_time, status, priority, cmd_id from sync_task_table";
ResultSet resultset = statement.executeQuery(query);
dm=new DefaultTableModel();
String columnNames[] = { "Column 1", "Column 2", "Column 3" };
// Create some data
String dataValues[][] = {
{ "12", "234", "67" },
{ "-123", "43", "853" },
{ "93", "89.2", "109" },
{ "279", "9033", "3092" }
};
// Create a new table instance
table = new JTable( dataValues, columnNames );
// Add the table to a scrolling pane
scrollPane = new JScrollPane( table );