retrieve data from database problem

this is my 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 java.lang.String;

import javax.swing.JOptionPane;

import java.sql.*;

import javax.swing.JTable;

import java.lang.Runtime;

public class sort extends JFrame implements ActionListener

{

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

JLabel lblshade;

JLabel lblshadeID;

JLabel lbltotal;

JTextField txtshade;

JTextField txtshadeID;

JTextField txttotal;

JButton btnview;

JButton btnnew;

JButton btnback;

String shade,shadeid, total;

Connection conn;

Statement stmt;

ResultSet rs;

ResultSetMetaData md;

String url;

String sql,sqln;

int colcount;

Vector columnNames = new Vector();

Vector data = new Vector();

public sort()

{

JPanel pane=new JPanel();

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

txtshade=new JTextField(10);

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

txtshadeID=new JTextField(10);

lbltotal = new JLabel("Total :");

txttotal = new JTextField(10);

btnview=new JButton("View Details");

btnnew=new JButton("New Shade");

btnback=new JButton("Back");

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

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

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

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

lbltotal.setBounds(184, 144, 120, 25);

txttotal.setBounds(352, 144, 120, 25);

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

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

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

//table.setBounds(600,200,152,32);

//table.setLocation(8,200);

//add labels to the panel

pane.add(lblshade);

pane.add(lblshadeID);

pane.add(txtshade);

pane.add(txtshadeID);

pane.add(lbltotal);

pane.add(txttotal);

pane.add(btnview);

pane.add(btnnew);

pane.add(btnback);

pane.setLayout(null);

frm.getContentPane().add(pane);

frm.setSize(800,700);

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);

}

public void connection()

{

url="jdbc:odbc:test";

try

{

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

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

stmt=conn.createStatement();

}

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()==btnview)

{

shade=txtshade.getText();

shadeid=txtshadeID.getText();

if(shade.length()==0 || shadeid.length()==0)

{

JOptionPane.showMessageDialog(null,"INVALID ENTRY","Note",2);

return;

}

txtshade.requestFocus();

//populate(shade,shadeid);

//btnview.setEnabled(false);

txtshade.setText("");

txtshadeID.setText("");

txtshade.requestFocus();

sql="SELECT total FROM Supplier WHERE shade = '"+shade+"' AND shadeid ='"+shadeid+"'";

try

{

rs=stmt.executeQuery(sql);

while(rs.next())

{

disableflds();

return;

}

//enableflds();

clsflds();

txtshadeID.setText(shadeid);

txtshade.requestFocus();

//rs.getString(total);

txttotal.setText( rs.getString());

}

catch(SQLException sqlexcep)

{

System.out.println("Error"+sqlexcep);

}

}

if(ae.getSource()==btnback)

{

mainfile obj=new mainfile();

frm.dispose();

}

}

public void disableflds()

{

txtshadeID.setEnabled(false);

txtshade.setEnabled(false);

txttotal.setEnabled(false);

}

public void clsflds()

{//jtxtsuppid,jtxtsupplier,jtxtquantity,jtxtdate,jtxtdenid,jtxtquality,jtxtshadeid,jtxtshade,jtxtambig,jtxtbatch;

txtshadeID.setText("");

txtshade.setText("");

txttotal.setText("");

}

}

in the database i have 3 fields

1.shade

2.shadeid

3.total

i want that when i give my shade and shadeid, the application should show me the total value in the textfield fetching it from the database.

plz help me

thanks.

[4960 byte] By [mansi_b85a] at [2007-11-26 22:07:13]
# 1
So what, exactly, is your problem/question?
masijade.a at 2007-7-10 10:52:33 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2

n the database i have 3 fields

1.shade

2.shadeid

3.total

All the 3 fields will be already filled with the data.

I want that when i enter the values of shade and shade id, the database should search for it in the database and the value of the "total" caorresponding to that particular shade and shadeid i entered should be shown to me in a text field after retriving it from the database.

mansi_b85a at 2007-7-10 10:52:33 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3

So what part of that are you having a problem with?

Are you getting an exception? If so paste it here.

Do you not know how to use JDBC? If so, read the JDBC tutorial.

Do you not know how to display it once you have it? If so, read the Swing tutorial.

If it is one of the last two points, then, after you have read the tutorial and given it a try, if you still have problems (and then a specific question), then come back and ask.

masijade.a at 2007-7-10 10:52:33 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...