
I want to retrive data(doctor name,specilization,date) from my sql database.
............................................................................
doctors name(JLabel1) jtextfield1 specialization(JLabel2) jtextfield2 date(Jlabel3) jtextfield3
jbutton ........................................................................... in above i show the gui of the programme wrote using netbeans desktop applications.i want to show related fields in another jframe.please send the code to me????

import java.awt.*;
import java.sql.*;
import javax.swing.*;
import java.awt.event.*;
class FormDemo
{
public static void main(String[]args){
JFrame f=new JFrame();
JPanel panel;
JLabel label1,label2;
final JTextField text1,text2;
label1 = new JLabel();
label1.setText("Name:");
text1 = new JTextField(20);
label2 = new JLabel();
label2.setText("Address:");
text2 = new JTextField(20);
panel=new JPanel(new GridLayout(2,2));
panel.add(label1);
panel.add(text1);
panel.add(label2);
panel.add(text2);
f.add(panel);
try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root" );
Statement st=conn.createStatement();
ResultSet rs=st.executeQuery("select * from data where id=1");
while(rs.next()){
text1.setText(rs.getString("name"));
text2.setText(rs.getString("address"));
}
}
catch(Exception e){}
f.pack();
f.setVisible(true);
}
}