Posted By:
deepakthomas
Posted On:
Wednesday, October 3, 2012 09:06 AM
For a test project that I am doing, I have a Japplet embedded in a piece of HTML code. The applet has a form which takes some user input through a text box. The data captured needs to be updated into a MySQL table. - The applet is displayed properly when the html page is opened in a browser. - The codes throws no error on submitting the user entered info. - But the table is not getting updated with the data. Code used to embed the applet in the html page is as shown below. ********************** [code] <html> <head> <title></title> <meta http-equi
More>>
For a test project that I am doing, I have a Japplet embedded in a piece of HTML code. The applet has a form which takes some user input through a text box. The data captured needs to be updated into a MySQL table.
- The applet is displayed properly when the html page is opened in a browser.
- The codes throws no error on submitting the user entered info.
- But the table is not getting updated with the data.
Code used to embed the applet in the html page is as shown below.
**********************
[code]
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<applet code="OBSPackage.UserHome" archive="OBSLibrary.jar" width="1500" height="600"></applet>
</body>
</html>
[/code]
**********************
The code inside the applet that updates the data into the table is as shown below.
**********************
[code]
int rs1=d.putData("insert into reg(uname,address,phno,email)values('"+name+"','"+address+"','"+ph+"','"+email+"')");
int rs2=d.putData("insert into login(username,password)values('"+username+"','"+pass+"')");
JOptionPane.showMessageDialog(this,"Registered Successfully");
[/code]
**********************
[b]NOTE:[/b] The data insertion is working properly when the applet is run independently in the applet viewer. The issue is only when it is accessed through a browser.
- Here is my jdbc code
Java Code:
[code]
public DBcon() {
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/db", "root", "deepak");
st = con.createStatement();
} catch (Exception e) {
System.out.println("Error" + e);
}
}
[/code]
- I am using Netbeans to create the applets. The MySQL DB is in the same machine, in the default location (programfiles/mysql/data). The netbeans project is saved in 'My Documents'. I am able to access the DB when I run the applet through appletviewer, but not when called through a browser.
What can i do to resolve the situation? I am using Netbeans.
<<Less