I am having an
applet page which is like an input form with the details name,age,etc...and a submit button.now i have to submit the details which is to be stored in my database.I have written the following code to display the input form in applet and another code is to update the details in database.please help me whether it is correct or not?
code: To display the input form in applet(JAgi.java)
public class JAgi
{
JFrame frame;
JPanel panel;
JLabel labelCardid;
JLabel labelName;
JTextField textCardid;
JTextField textName;
JButton loginButton=new JButton("Enter");
public JAgi()
{
panel=new JPanel();
frame=new JFrame("Customer Details");
frame.setSize(300,300);
frame.setVisible(true);
frame.getContentPane().add(panel);
labelCardid = new JLabel("Card ID:");
labelName = new JLabel("Name:");
textCardid = new JTextField(15);
textName = new JTextField(15);
panel.add(labelCardid);
panel.add(textCardid);
panel.add(labelName);
panel.add(textName);
panel.add(loginButton);
}
public static void main(
String args[])
{
new JAgi();
}
}
Code:To get the values and to insert into db(JAgidb.java)
public class JAgidb
{
String Cardid=request.getParameter("textcardid");
String Name=request.getParameter("textName");
try
{
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection C = DriverManager.getConnection("jdbc:mysql://192.168.1.5:3306/test","dialer","1234");
Statement st = C.createStatement();
ResultSet rs=null;
String query="select * from credit_cards";
rs=st.executeQuery(query);
st.executeUpdate("INSERT INTO `credit_cards` (`cardid` , `name` )VALUES('"+ Cardid +"' , '"+ Name +"')");
}
catch(Exception e)
{}
}
I this code is correct ,how to submit that applet page to this inserting page?whether i have to use onclick event?if so where i have to write?
please help me.