Web enabled Applet-Database connectivity issues
0 posts in topic
Thread View Thread View

Web enabled Applet-Database connectivity issues...
Wed Oct 03, 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.
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <applet code="OBSPackage.UserHome" archive="OBSLibrary.jar" width="1500" height="600"></applet>

The code inside the applet that updates the data into the table is as shown below.
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");
[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:
public DBcon() {
        try {
            Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/db", "root", "deepak");
            st = con.createStatement();
        } catch (Exception e) {
            System.out.println("Error" + e);
- 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.
About | Sitemap | Contact