Basic Quicktable As a basic table, we will add
quicktable to a JFrame with the navigation bars.
import javax.swing.*;
import quick.dbtable.*;
import java.sql.*;
public class QuickTableFrame extends JFrame
{
public QuickTableFrame()
{
//set Frame properties
setSize(300,200);
setVisible(true);
//create a new quicktable
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();
//fetch the data from database to fill
the table
dBTable1.refresh();
}
catch(SQLException e)
{
e.printStackTrace();
}
catch(ClassNotFoundException e)
{
e.printStackTrace();
}
}
public static void main(String[] args)
{
//create a new table frame
QuickTableFrame myframe = new QuickTableFrame();
}
}
Your Quicktable is
here!
|