import javax.swing.*;
import quick.dbtable.*;
import java.sql.*;
import java.awt.event.*;
public class QuickTableFrame extends JFrame
{
public QuickTableFrame()
{
//set Frame properties
setSize(300,200);
setVisible(true);
//create a new quicktable
final quick.dbtable.DBTable dBTable1 = new quick.dbtable.DBTable();
//add to frame
getContentPane().add(dBTable1);
//set the database driver to be used, we are using jdbc-odbc driver
dBTable1.setDatabaseDriver("sun.jdbc.odbc.JdbcOdbcDriver");
/*
set the jdbc url,"quicktabledemo" is the data source we have created
for the database
*/
dBTable1.setJdbcUrl("jdbc:odbc:quicktabledemo");
// set the select statement which should be used by the table
dBTable1.setSelectSql("select * from employee");
//to create the navigation bars for the table
dBTable1.createControlPanel();
try
{
//connect to database & create a connection
dBTable1.connectDatabase();
}
catch(SQLException e)
{
e.printStackTrace();
}
catch(ClassNotFoundException e)
{
e.printStackTrace();
}
//create a timer
Timer timer = new Timer(5000, new ActionListener() { //5000 = 5 sec
public void actionPerformed(ActionEvent evt) {
//refresh quicktable
try
{
//fetch the data from database to fill the table
dBTable1.refresh();
}
catch(SQLException e)
{
e.printStackTrace();
}
}
});
//start the timer
timer.start();
}
public static void main(String[] args)
{
//create a new table frame
QuickTableFrame myframe = new QuickTableFrame();
}
}