import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
public class BookSales extends JFrame implements ItemListener
{
JComboBox cb;
String head[]={"SalesID","Month","Amount"};
String as[][]=new String[10][10];
public BookSales()
{
setLayout(null);
cb=new JComboBox();
cb.setBounds(350,20,100,20);
cb.addItem("JANUARY");
cb.addItem("FEBRUARY");
cb.addItem("MARCH");
cb.addItem("APRIL");
cb.addItem("MAY");
cb.addItem("JUN");
cb.addItem("JULY");
cb.addItem("AUGUST");
cb.addItem("SEPTEMBER");
cb.addItem("OCTOBER");
cb.addItem("NOVEMBER");
cb.addItem("DECEMBER");
add(cb);
cb.addItemListener(this);
setSize(500,400);
setVisible(true);
}
public void itemStateChanged(ItemEvent ie)
{
String str=cb.getSelectedItem().toString();
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:BCA");
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select * from BookSale where Month='"+str+"'");
int i=0;
while(rs.next())
{
as[i][0]=rs.getString(1);
as[i][1]=rs.getString(2);
as[i][2]=rs.getString(3);
i++;
}
con.close();
JTable jt=new JTable(as,head);
JScrollPane pane=new JScrollPane(jt);
pane.setBounds(0,0,300,400);
add(pane);
}
catch(Exception e)
{
System.out.println(e);
}
}
public static void main(String args[])
{
new BookSales();
}
}