
import java.sql.*;
import javax.swing.JOptionPane;
public class NewJFrame extends javax.swing.JFrame {
Connection con=null;
Statement st=null;
ResultSet rs=null;
public NewJFrame() {
initComponents();
}
private void initComponents() {
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
{
try
Class.forName("java.sql.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost/ACCOUNT","root","ADMIN");
st=con.createStatement();
String query="SELECT * FROM BANK";
rs=st.executeQuery(query);
if(rs.next())
{
String n=rs.getString("name");
String b=rs.getString("address");
String s=rs.getString("phone");
String t=rs.getString("branch");
}
else
{
JOptionPane.showMessageDialog(null,"no record");
}
}
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null,"error");
}
CAN ANYONE HELP ME IN FINDING THE ERRORS IN DIS CODE AND WATS REALLY A PROBLEM WITH THIS?

Hi Friend,
We have modified your code, there were many errors.Try this:
import java.sql.*;
import javax.swing.*;
import java.awt.event.*;;
public class NewJFrame extends JFrame {
Connection con=null;
Statement st=null;
ResultSet rs=null;
public NewJFrame() {
initComponents();
}
private void initComponents() {
setLayout(null);
JButton b=new JButton("Retrieve");
b.setBounds(10,10,100,20);
add(b);
setSize(300,100);
setVisible(true);
b.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt) {
try{
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root");
st=con.createStatement();
String query="SELECT * FROM employee";
rs=st.executeQuery(query);
int count=0;
while(rs.next()){
String n=rs.getString("name");
String b=rs.getString("address");
String s=rs.getString("contactNo");
String t=rs.getString("email");
System.out.println(n+" "+b+" "+s+" "+t);
count++;
}
if(count<0){
JOptionPane.showMessageDialog(null,"no record");
}
}
catch(Exception e) {
JOptionPane.showMessageDialog(null,"error");
}
}
});
}
public static void main(String[]args){
new NewJFrame();
}
}
For more information, visit the following link:
Thanks

thanks thankz... thnks a lot frnd.. actually dt code s printed in ma txt buk and wn i tryd to run on ma system oh god... wt to say full error... can u plz help me to design a gui programme with the help of d same.. i mean we'v to input data in a designed gui frame and d data which v input should get saved in a mysql table... plz if u've any such programmes kindly help me..