import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import javax.swing.JButton;
import javax.swing.JFrame;
import com.sun.rowset.CachedRowSetImpl;
import quick.dbtable.Column;
import quick.dbtable.DBTable;
public class Apl {
/**
* @param args
*/
public static void main(String[] args) {
final Connection connection;
JFrame frame = new JFrame();
frame.setSize(320, 240);
final DBTable table = new DBTable();
String connectionString;
String server = "localhost";
String database = "tsf_sf";
String username = "sa";
String password = "tsf01d";
String url = "jdbc:jtds:sqlserver://";
String driver = "net.sourceforge.jtds.jdbc.Driver";
try {
Class.forName(driver);
connectionString = url + server + ";DatabaseName=" + database;
connection = java.sql.DriverManager.getConnection(
connectionString, username, password);
CachedRowSetImpl rowSet;
rowSet = new CachedRowSetImpl();
rowSet.setCommand("select project_id, project_vrs_id, tab_id, col_id from col");
rowSet.execute(connection);
table.refresh(rowSet.getOriginal());
Column projectId = table.getColumn(0);
projectId.setHeaderValue("Project");
Column projectVrsId = table.getColumn(1);
projectVrsId.setHeaderValue("Project version");
Column tabId = table.getColumn(2);
tabId.setHeaderValue("Table");
Column colId = table.getColumn(3);
colId.setHeaderValue("Column");
JButton button = new JButton("Refresh");
button.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
try {
table.useOldColumnProperties(true);
CachedRowSetImpl rowSet = new CachedRowSetImpl();
rowSet.setCommand("select project_id, project_vrs_id, tab_id, col_id from col");
rowSet.execute(connection);
table.refresh(rowSet.getOriginal());
} catch (Exception exception) {
exception.printStackTrace();
}
}
});
frame.setLayout(new BorderLayout());
frame.add(table, BorderLayout.CENTER);
frame.add(button, BorderLayout.SOUTH);
} catch (Exception exception) {
exception.printStackTrace();
}
frame.setVisible(true);
}
}