
what is code for diplay on java swing internal frame form MYSQL DB pls send

Here is a code of creating form on jinternalframe and connect to mysql.
import java.io.*;
import java.sql.*;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class JInternalFormDemo extends JDesktopPane {
public static void main(final String[] args) throws IOException {
final JInternalFormDemo desktop = new JInternalFormDemo();
desktop.addForm();
final JFrame frame = new JFrame("Show Image");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(BorderLayout.CENTER, desktop);
frame.setSize(600, 100);
frame.setVisible(true);
}
public void addForm() {
add(createFrame());
}
private static int frames;
private JInternalFrame createFrame() {
final JInternalFrame frame = new JInternalFrame("Form ");
JButton ADD=new JButton("Submit");
JPanel panel=new JPanel(new GridLayout(3,2));
JLabel label1=new JLabel("Name");
JLabel label2=new JLabel("Address");
final JTextField text1=new JTextField(20);
final JTextField text2=new JTextField(20);
panel.add(label1);
panel.add(text1);
panel.add(label2);
panel.add(text2);
panel.add(ADD);
frame.add(panel);
ADD.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae){
String value1=text1.getText();
String value2=text2.getText();
try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root" );
Statement st=conn.createStatement();
st.executeUpdate("insert into data(name,address) values('"+value1+"','"+value2+"')");
JOptionPane.showMessageDialog(null,"Inserted Successfully!");
text1.setText(" ");
text2.setText(" ");
}
catch(Exception e){}
}
});
frame.pack();
frame.setVisible(true);
frame.setLocation(40 * frames, 40 * frames);
return frame;
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.