Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Java Applet and MySQL

  1. #1
    Junior Member
    Join Date
    Apr 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Java Applet and MySQL

    I'm working on a simple inventory program using a Java applet that connects to a MySQL database. Program works fine if I just compile and run it from Netbeans, but it is throwing an exception once I add an applet wrapper.

    The java console is only spitting out "createGUI didn't complete successfully" and not the stacktrace or exception message that I need for troubleshooting. What gives?

    I've had TONS of trouble getting the html applet tag to work at all. Is this method antiquated?

    Developing an Applet (The Java™ Tutorials > Deployment > Applets)


    <html>
    <head>
    <title>
    Testing Page for Java Applet
    </title>
    </head>
    <body>
    <p>Begin body...</p>
     
       <applet code="sqlconnection.appletWrapper.class" width=400 height=400 archive="SQLConnection.jar>
       <hr>
       Replacement Text
       <hr>
       </applet>
     
    <p>End body...</p>
    </body>
    </html>

    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    package sqlconnection;
     
    /**
     *
     * @author Master
     */
    import javax.swing.JApplet;
    import javax.swing.SwingUtilities;
     
    public class appletWrapper extends JApplet {
        //Called when this applet is loaded into the browser.
        @Override
        public void init() {
            //Execute a job on the event-dispatching thread; creating this applet's GUI.
            try {
                SwingUtilities.invokeAndWait(new Runnable() {
                    public void run() {
                        createGUI();
                    }
                });
            } catch (Exception e) {
                System.out.println(e.getMessage());
                e.printStackTrace();
                System.out.println(e.toString());
                System.out.println("createGUI didn't complete successfully");
            }
        }
     
        private void createGUI() {
            //Create and set up the content pane.
            System.out.println("inside createGUI");
            MainPanel newContentPane = new MainPanel();
            newContentPane.setOpaque(true); 
            setContentPane(newContentPane);
            System.out.println("leaving createGUI");
        }
    }


  2. #2
    Junior Member
    Join Date
    Aug 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Java Applet and MySQL

    My great thanks to this post. The code given by you is very useful. It is nice combination of Java applet
    and MySQL. I find code very useful. I really appreciate your work. I am sure many people will find it very useful.

  3. #3
    Junior Member
    Join Date
    Apr 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Java Applet and MySQL

    Thanks! I never did get it to work reliably. The program is fantastic in a JFrame, but moving it into an applet really didn't work out for me. What does your HTML look like?

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Java Applet and MySQL

    java console is only spitting out "createGUI didn't complete successfully"
    The code shows that it also does a printStackTrace() in the catch block.
    The problem would be shown in that stack trace message. What was the full contents of the java console?

  5. #5
    Junior Member
    Join Date
    Apr 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Java Applet and MySQL

    That's why I was specific about what was in the console. That's it. No stack trace printed. This was a long time ago and I don't even have the applet code anymore.

Similar Threads

  1. Bundling mysql-connector with my applet
    By corykendall in forum Java Applets
    Replies: 2
    Last Post: November 8th, 2013, 08:23 PM
  2. Java Applet Coding Help?
    By Drag01 in forum Java Applets
    Replies: 1
    Last Post: April 26th, 2012, 07:03 AM
  3. Need help with java applet game.
    By vlan in forum What's Wrong With My Code?
    Replies: 0
    Last Post: April 10th, 2010, 04:18 AM
  4. Connectivity problem:MySQL and Java
    By Pragya in forum JDBC & Databases
    Replies: 2
    Last Post: January 22nd, 2010, 03:58 AM
  5. Use of Unicode 5.1 in MySQL DB with Java
    By Desert Fox in forum JDBC & Databases
    Replies: 2
    Last Post: November 12th, 2008, 08:29 AM