Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7773787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:12:55+00:00 2026-06-01T17:12:55+00:00

I have an applet which when I test run in Eclipse works perfectly yet

  • 0

I have an applet which when I test run in Eclipse works perfectly yet when I move into the browser it doesn’t seem to work.

I have read already that applets are not used much anymore but I still want to learn about them for a variety of reasons.

Here is my code. Like I said it works as intended when run in eclipse.

public class WPStool extends Applet implements ActionListener
{
 /**
     * 
     */
 private static final long serialVersionUID = 6920052961843268403L;
 Label lblCustNum, lblCustName, lblAccount, lblEmpID, lblSuccess;
 TextField txtCustNum, txtCustName, txtAccount, txtEmpID;
 Button bEnter;
 boolean blnCorrect;

 public void init()
 {
     lblCustNum = new Label("Customer #");
  add(lblCustNum);

  txtCustNum = new TextField(20);
  add(txtCustNum);

  lblCustName = new Label("Customer Name");
  add(lblCustName);

  txtCustName = new TextField(20);
  add(txtCustName);

  lblAccount = new Label("Account Type");
  add(lblAccount);

  txtAccount = new TextField(20);
  add(txtAccount);

  lblEmpID = new Label("EmployeeID");
  add(lblEmpID);

  txtEmpID = new TextField(20);
  add(txtEmpID);

  bEnter = new Button("Enter");
  add(bEnter);
  bEnter.addActionListener(this);
 }

 public void actionPerformed(ActionEvent e)
 {

  if (e.getSource() == bEnter)
    {
        //registerUser();
        int custNum = Integer.parseInt(txtCustNum.getText());
        int empID = Integer.parseInt(txtEmpID.getText());
        enterInfo(custNum, txtCustName.getText(), txtAccount.getText(), empID);
        txtCustNum.setText("");
        txtCustName.setText("");
        txtAccount.setText("");
        txtEmpID.setText("");
    }
 }



public void enterInfo(int custNuma, String custNamea, String accounta, int empIDa)
{
    Connection con = getConnection();
    try
    {
        Statement s = con.createStatement();
        String select = "INSERT INTO  customerInfo (custNum , custName, account ,empID) VALUES ("+ custNuma +",  '"+ custNamea +"',  '"+ accounta +"',  "+ empIDa +")";
        //String select = "INSERT INTO  customerInfo (custNum , custName, account ,empID) VALUES (123,  'Jim John Joe',  'New Account', 1234)";
        s.executeUpdate(select);
        lblSuccess = new Label("Success!");
        add(lblSuccess);

    }
    catch (SQLException e)
    {
        System.out.println("getClasses method: " + e.getMessage());
        lblSuccess = new Label("FAIL!");
        add(lblSuccess);
    }
}

private Connection getConnection()
{
    Connection con = null;
    try
    {
        Class.forName("com.mysql.jdbc.Driver");
        String url = "jdbc:mysql://localhost/wps";
        String user = "root";
        String pw = "";
        con = DriverManager.getConnection(url, user, pw);
    }
    catch (ClassNotFoundException e)
    {
        System.out.println("getConnection ClassNotFound: " + e.getMessage());
        System.exit(0);
    }
    catch (SQLException e)
    {
        System.out.println("getConnection SQL: " + e.getMessage());
        System.exit(0);
    }
    return con;
}

}

Is there some extra browser settings I need to setup? Also. I am importing the JDBC so I can use sql, do I need to add this somehow?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T17:12:56+00:00Added an answer on June 1, 2026 at 5:12 pm

    Maybe from the browser the java code is not able to connect to the database.

    You have to change your application structure, and separate the applet part from the server part. Put in the applet part all the user interface logic, then connect to the server part, via RMI or Web Service, sending data, and on server side connect to the database.

    Another point event if your client would be able to connect to the database, if you release the applet with connection url jdbc:mysql://localhost/wps then every client will try to connect to a database on the same machine that run applet. That is, if you have 10 clients, every try will search for the database on itself, because you use localhost.

    However I suggest you to separate your application login in the two part I describe you above.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Java applet which doesn't need any special privileges to run (i.e,
I have an applet which runs in a browser and is called from Javascript.
I have written a java applet which opens a JFrame (so when run in
I have developed an applet java with Eclipse, which is included in MyPage.html. I
I have a client application which runs as a Java applet from a user's
Applications which run on mobile devices have special user interface requirements. I think Apple
I have read from some article that say's Apple doesn't approve the application which
I have an eclipse workspace containing two projects, which I'll call foo-lib and foo-app.
I have applet which use jna Pointer class. The applet code is: import com.sun.jna.*;
I have this test app: import java.applet.*; import java.awt.*; import java.net.URL; public class Test

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.