I want to extract data from database tables and show into a table from in JTable
.
Here is some code i want to add the data from database base in array dataValues [] []
in this i store values in dataValues [][]
static but i want to store values in dataValues[][]
from the database table.
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 );