JTable-JDBC connectivity, PLZ HELP.......URGENT

i hav nade a JTable n i hav 8 columns in it and database. i hav made database in oracle n java in jdk1.3. 8 columns r:

1. Supplier

2. SupplierID

3. DenearID

4. Date

5. Quantity

6. Shade

7 ShadeID

8.Batch

now i want to retrieve the data from the database n show it in JTable. I want to retrieve it when i enter Shade n ShadeID in textarea n press OK, it should be able to show me other fields in JTable.

i m new to java n oracle.

plz help me out with it. plz tell me how do i retrieve it frm oracle db.

i m sending my java code.

import javax.swing.*;

import java.awt.event.*;

import java.lang.String;

import java.io.*;

import java.util.*;

import java.text.*;

import java.awt.*;

import javax.swing.filechooser.*;

import Record;

import javax.swing.JOptionPane;

import javax.swing.JTable;

import java.lang.Runtime;

public class sort1 extends JFrame

{

JFrame frm=new JFrame("NABEL VIGILANCE SOFTWARE");

JLabel lblshade;

JLabel lblshadeID;

JTextField txtshade;

JTextField txtshadeID;

JButton btnview;

JButton btnnew;

JButton btnback;

JTable table;

JScrollPane jsp;

//int v;

//int h;

String url,sql;

String[] rwData;

int rec,rwCnt,coln,flag,nrows,reply;

Vector dataRows;

Connection conn;

Statement stmt;

ResultSet rs;

public sort1()

{

JPanel pane=new JPanel();

lblshade=new JLabel("Enter Shade : ");

txtshade=new JTextField(10);

lblshadeID=new JLabel("Enter ShadeID : ");

txtshadeID=new JTextField(10);

//txtpass.setEchoChar('*');

btnview=new JButton("View Details");

btnnew=new JButton("New Shade");

btnback=new JButton("Back");

final String[] colHeads = {"Supplier", "SupplierID", "Quantity", "Date","Denear ID", "Shade ID", "Shade", "Batch" };

final Object[][] data = {

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

};

pane.setLayout(null);

table = new JTable(data, colHeads);

//v = ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;

//h = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;

jsp = new JScrollPane(table);

lblshade.setBounds(184, 48, 120, 25);

lblshadeID.setBounds(184, 96, 120, 25);

txtshade.setBounds(352, 48, 120, 25);

txtshadeID.setBounds(352, 96, 120, 25);

btnview.setBounds(600, 32, 152, 32);

btnnew.setBounds(600, 80, 152, 32);

btnback.setBounds(600, 128, 152, 32);

table.setSize(1000,500);

table.setLocation(8,200);

//add labels to the panel

pane.add(lblshade);

pane.add(lblshadeID);

pane.add(txtshade);

pane.add(txtshadeID);

pane.add(btnview);

pane.add(btnnew);

pane.add(btnback);

pane.add(table);

pane.add(jsp);

frm.getContentPane().add(pane);

frm.setSize(430,350);

frm.setVisible(true);

frm.setResizable(true);

WindowListener listener=new WindowAdapter()

{

public void windowClosing(WindowEvent winevt)

{

System.exit(0);

}

};

frm.addWindowListener(listener);

//btnview.addActionListener(this);

//btnnew.addActionListener(this);

btnback.addActionListener(this);

//chgpass.setEnabled(false);

}

public void connection()

{

url="jdbc:odbc:test";

try

{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

conn=DriverManager.getConnection(url,"scott","tiger");

stmt=conn.createStatement();

//jsave.setEnabled(false);

disableflds();

}

catch(SQLException sqlexcep)

{

System.out.println("Cannot connect to server"+sqlexcep);

}

catch(ClassNotFoundException cls)

{

System.out.println("Cannot find the class"+cls);

}

}

public void actionPerformed(ActionEvent ae)

{

if(ae.getSource()==jback)

{mainfile obj=new mainfile();

frm.dispose();

}

public static void main(String[] args)

{

sort1 demo=new sort1();

/*JFrame frm=new JFrame("NABEL VIGILANCE SOFTWARE");

frm.setContentPane(demo);

frm.setSize(430,350);

frm.setVisible(true);

frm.setResizable(true);

WindowListener listener=new WindowAdapter()

{

public void windowClosing(WindowEvent winevt)

{

System.exit(0);

}

};

frm.addWindowListener(listener);*/

}

}

ithank u in advance.

[5954 byte] By [mansi_b85a] at [2007-11-26 20:04:54]
# 1

So look at a JDBC Totorial at Sun to find pout how to read the data, then store the info in an Object[][] two dimensional array, and create your JTable using that. If you later need to retrieve the data again and refresh your JTable, then, once again, read and store the data as above and create a new DefaultTableModel with it and call JTable's setModal method with that.

masijade.a at 2007-7-9 23:05:37 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2

final Object[][] data = {

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

{"","","","","","","",""},

WTF is this?

bckrispia at 2007-7-9 23:05:37 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3

> WTF is this?

Seemingly being used to initiate an empty JTable of a specific size. The worst possible way in the world to do it, but hey, to each his own. It probably never occurred to him that it might be done another way, and most definately, it never occurred to him to read the API to see if there might be another (read inifinately better) way to do this.

;-)

masijade.a at 2007-7-9 23:05:38 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 4
> > WTF is this?> > Seemingly being used to initiate an empty JTable of a> specific size. Yes, I know. That was a 'rhetorical WTF'. :-D
bckrispia at 2007-7-9 23:05:38 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 5

> > > WTF is this?

> >

> > Seemingly being used to initiate an empty JTable of

> a

> > specific size.

>

> Yes, I know. That was a 'rhetorical WTF'. :-D

I figured that, I was just hoping the OP would read the text and maybe take a few lessons from it.

Edit: Forgot my smiley. ;-)

masijade.a at 2007-7-9 23:05:38 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...