Posted Wednesday, December 31, 1969 @ 23:59:59
I am using quicktable in an applet deployed on TOMCAT and I've encountered the following problem. If I modify a cell value and then close Internet Explorer without saving the modified data, then the browser hangs. The problem can be replicated with the following code and also occurred with diffrent JDBC drivers.
HTML Test Page
testdbconnection.DBViewer will appear below in a Java enabled browser.
package testdbconnection;
import java.applet.Applet;
import java.awt.*;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.PrintStream;
import java.util.EventObject;
import javax.swing.*;
import javax.swing.text.JTextComponent;
import quick.dbtable.DBTable;
public class DBViewer extends JApplet
implements ActionListener
{
public String getParameter(String key, String def)
{
return isStandalone ? System.getProperty(key, def) : getParameter(key) == null ? def : getParameter(key);
}
public DBViewer()
{
isStandalone = false;
jdbcPanel = new JPanel();
queryPanel = new JPanel();
quickTable = new DBTable();
jLabel1 = new JLabel();
jdbcUrlText = new JTextField();
gridLayout1 = new GridLayout();
jLabel2 = new JLabel();
driverText = new JTextField();
jLabel3 = new JLabel();
userText = new JTextField();
jLabel4 = new JLabel();
passwordText = new JPasswordField();
queryText = new JTextArea();
runButton = new JButton();
borderLayout1 = new BorderLayout();
connectButton = new JButton();
copyButton = new JButton();
pasteButton = new JButton();
jLabel5 = new JLabel();
jLabel6 = new JLabel();
skinCombo = new JComboBox();
}
public void init()
{
try
{
jbInit();
}
catch(Exception e)
{
e.printStackTrace();
}
}
private void jbInit()
throws Exception
{
setSize(800, 600);
jdbcPanel.setLayout(gridLayout1);
queryPanel.setLayout(borderLayout1);
jLabel1.setText("Jdbc Driver");
jLabel3.setText("User");
jLabel4.setText("Password");
queryText.setColumns(30);
queryText.setRows(5);
runButton.setText("Run");
borderLayout1.setVgap(5);
connectButton.setText("Connect");
copyButton.setText("Copy");
pasteButton.setText("Paste");
jLabel6.setText("Skin");
jLabel5.setText("Tip: Enter Database properties, click connect, then run query");
borderLayout1.setHgap(5);
gridLayout1.setRows(6);
gridLayout1.setHgap(5);
gridLayout1.setColumns(2);
gridLayout1.setVgap(5);
jLabel2.setText("jdbc url");
getContentPane().add(jdbcPanel, "North");
jdbcPanel.add(jLabel1, null);
jdbcPanel.add(driverText, null);
jdbcPanel.add(jLabel2, null);
jdbcPanel.add(jdbcUrlText, null);
jdbcPanel.add(jLabel3, null);
jdbcPanel.add(userText, null);
jdbcPanel.add(jLabel4, null);
jdbcPanel.add(passwordText, null);
jdbcPanel.add(connectButton, null);
jdbcPanel.add(jLabel5, null);
jdbcPanel.add(jLabel6, null);
jdbcPanel.add(skinCombo, null);
jdbcPanel.add(copyButton, null);
jdbcPanel.add(pasteButton, null);
getContentPane().add(queryPanel, "South");
JLabel jl = new JLabel("Enter Query");
jLabel1.setHorizontalAlignment(4);
jLabel2.setHorizontalAlignment(4);
jLabel3.setHorizontalAlignment(4);
jLabel4.setHorizontalAlignment(4);
jLabel5.setHorizontalAlignment(4);
jLabel6.setHorizontalAlignment(4);
JScrollPane queryPane = new JScrollPane(queryText);
queryPanel.add(jl, "West");
queryPanel.add(queryPane, "Center");
queryPanel.add(runButton, "East");
quickTable.createControlPanel();
getContentPane().add(quickTable, "Center");
skinCombo.addItem("None");
skinCombo.addItem("Simple");
skinCombo.addItem("Cool");
skinCombo.addItem("Pulse");
connectButton.addActionListener(this);
runButton.addActionListener(this);
skinCombo.addActionListener(this);
copyButton.addActionListener(this);
pasteButton.addActionListener(this);
driverText.setText("weblogic.jdbc.mssqlserver4.Driver");
jdbcUrlText.setText("jdbc:weblogic:mssqlserver4:test@testsvr:1433");
userText.setText("test");
passwordText.setText("test");
queryText.setText("select * from client");
runButton.setEnabled(false);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource() == connectButton)
{
try
{
if(quickTable.getConnection() != null)
quickTable.close();
quickTable.setDatabaseDriver(driverText.getText());
quickTable.setJdbcUrl(jdbcUrlText.getText());
quickTable.setUser(userText.getText());
quickTable.setPassword(String.copyValueOf(passwordText.getPassword()));
quickTable.connectDatabase();
}
catch(Exception ex)
{
ex.printStackTrace();
return;
}
runButton.setEnabled(true);
} else
if(e.getSource() == runButton)
try
{
quickTable.enableExcelCopyPaste();
quickTable.setSelectSql(queryText.getText());
quickTable.refresh();
System.out.println();
}
catch(Exception ex)
{
ex.printStackTrace();
}
else
if(e.getSource() == skinCombo)
{
String selection = (String)skinCombo.getSelectedItem();
quickTable.setSkin(null);
} else
if(e.getSource() == copyButton)
quickTable.copyToClipboard(null);
else
if(e.getSource() == pasteButton)
quickTable.pasteFromClipboard();
}
public void start()
{
}
public void stop()
{
}
public void destroy()
{
}
public String getAppletInfo()
{
return "Applet Information";
}
public String[][] getParameterInfo()
{
return null;
}
public static void main(String args[])
{
DBViewer applet = new DBViewer();
applet.isStandalone = true;
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(3);
frame.setTitle("Applet Frame");
frame.getContentPane().add(applet, "Center");
applet.init();
applet.start();
frame.setSize(400, 320);
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
frame.setLocation((d.width - frame.getSize().width) / 2, (d.height - frame.getSize().height) / 2);
frame.setVisible(true);
}
boolean isStandalone;
JPanel jdbcPanel;
JPanel queryPanel;
DBTable quickTable;
JLabel jLabel1;
JTextField jdbcUrlText;
GridLayout gridLayout1;
JLabel jLabel2;
JTextField driverText;
JLabel jLabel3;
JTextField userText;
JLabel jLabel4;
JPasswordField passwordText;
JTextArea queryText;
JButton runButton;
BorderLayout borderLayout1;
JButton connectButton;
JButton copyButton;
JButton pasteButton;
JLabel jLabel5;
JLabel jLabel6;
JComboBox skinCombo;
private StringSelection stsel;
private String rowstring;
private String value;
private Clipboard system;
}