import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.table.*;
import java.sql.*;
public class SQLite_Table extends JFrame
{ JTextField hostField;
  JTextField tableField;
  JTextArea queryField;
  QueryTableModel qtm;
  String s="jdbc:sqlite:";
  static final long serialVersionUID = 8597941330711875390L;
  public SQLite_Table(String table_name) throws ClassNotFoundException
  {      super("SQLite veritaban? SQL tablo sorgusu");
	     Class.forName("org.sqlite.JDBC");
	     Connection connection = null;
    //addWindowListener(new BasicWindowMonitor());
         setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
        setSize(500,300);
    qtm=new QueryTableModel();
    JTable table=new JTable(qtm);
    JScrollPane scrollpane=new JScrollPane(table);
    JPanel p1=new JPanel();
    p1.setLayout(new GridLayout(3,2));
    p1.add(new JLabel(" veritaban?'n?n ismini giriniz :"));
    p1.add(hostField=new JTextField("VT.db"));
    p1.add(new JLabel("SQL deyimini giriniz :"));
    p1.add(queryField=new JTextArea("select * from "+table_name));
    p1.add(new JLabel("veri taban?n? gönderiniz:"));
    JButton jb=new JButton("veri taban? sorgusunu çal??t?r?n?z");
    jb.addActionListener(new ActionListener()
      {
      public void actionPerformed(ActionEvent e)
        {
        qtm.setHostURL(s+hostField.getText().trim());
        qtm.setQuery(queryField.getText().trim());
        }
      }); // jb.addActionlistener
  p1.add(jb);
  getContentPane().add(p1,BorderLayout.NORTH);
  getContentPane().add(scrollpane,BorderLayout.CENTER);
  } //DatabaseTest()
  public void setQuerry(String s)
  {qtm.setHostURL(s+hostField.getText().trim());
   qtm.setQuery(s.trim());
  }
  public static void main(String args[])
  { String table_name="VT1";
    try
    {
	 SQLite_Table tt=new SQLite_Table(table_name);
     tt.setVisible(true);
    } catch(ClassNotFoundException e)
    {
      // "out of memory" mesaj? veri taban?n?n bulunamad??? anlam?na gelir
      System.err.println(e.getMessage());
    }
  }
}
