Results 1 to 8 of 8
  1. #1
    HSN
    HSN is offline Member
    Join Date
    Jun 2011
    Posts
    5
    Rep Power
    0

    Exclamation problem while using .class file

    Hi Guys,

    I'm a new member in this forum
    and I've used to register to have a small hint with my project

    I have done a game using JApplet and its working greate on netbeans and it connects to mysql and select,insert,delete & upgrade
    but when I build the project and run it from the internet explorer
    the applet didn't connect to the DB

    I've tried this code to see if .class file connects to the DB
    Java Code:
        public String t()
        {
            String temp="";
            Class driver_class=null;
            try {
            driver_class = Class.forName("com.mysql.jdbc.Driver");
            } catch (ClassNotFoundException e) {
            e.printStackTrace();
            }
            temp=("Found driver " + driver_class);
            return temp;
        }
        public void paint(Graphics g)
        {
            super.paint(g);
            if(t().equals(""))
                g.drawString("Driver Not Found", getWidth()/2, getHeight()/2);
            else
                g.drawString(t(), getWidth()/2, getHeight()/2);
        }
    when I run this code in NetBeans
    I get
    "Found driver com.mysql.jdbc.Driver" as a result
    and when I run the .class file I get "Driver Not Found"

    I know the problem (not loading the JDBC Driver) but I didn't know what to do
    please help me I have to give this project to my doctor tomorrow & thank you alot .

    best regards,

    HSN.

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,014
    Rep Power
    20

    Default

    Is your mysql jdbc jar file in the runtime class path?
    (The answer would be no, otherwise you wouldn't get that exception)

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,421
    Rep Power
    25

    Default

    when I run the .class file I get "Driver Not Found"
    Can you show how you "run the class"? If its an applet, normally it executes in a browser. Is the html and class file on local drive or loaded from a server? Does the html <APPLET tag's archive= attribute point to the jar file with the driver?

  4. #4
    HSN
    HSN is offline Member
    Join Date
    Jun 2011
    Posts
    5
    Rep Power
    0

    Default

    Quote Originally Posted by Norm View Post
    Can you show how you "run the class"? If its an applet, normally it executes in a browser. Is the html and class file on local drive or loaded from a server? Does the html <APPLET tag's archive= attribute point to the jar file with the driver?

    sorry for the bad english
    but I didnt speak English,

    "run the class" is to open it with the browser using the built files in file Build which call the class files that I have to use them in my project

    and my html <applet tags archive= attribute point to the .class file not jar file

    If you want we can have private chat on msn and enter my pc using the "teamviewer" to see the problem I have
    ok ?

    thank you dude.

  5. #5
    HSN
    HSN is offline Member
    Join Date
    Jun 2011
    Posts
    5
    Rep Power
    0

    Default

    Quote Originally Posted by Tolls View Post
    Is your mysql jdbc jar file in the runtime class path?
    (The answer would be no, otherwise you wouldn't get that exception)
    I know that dude but I didn't know what to do exactly
    please tell me if you know the solution

    best regards,

    HSN

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,421
    Rep Power
    25

    Default

    The Applet tag's code= should be to the classname. The archive= should point to a jar file.

    Set the html <APPLET tag's archive= attribute to point to the jar file with the driver.

  7. #7
    HSN
    HSN is offline Member
    Join Date
    Jun 2011
    Posts
    5
    Rep Power
    0

    Default

    okay dude I will try that now and see what will happen

  8. #8
    HSN
    HSN is offline Member
    Join Date
    Jun 2011
    Posts
    5
    Rep Power
    0

    Thumbs up

    Quote Originally Posted by Norm View Post
    The Applet tag's code= should be to the classname. The archive= should point to a jar file.

    Set the html <APPLET tag's archive= attribute to point to the jar file with the driver.

    Thanks Sir, it works perfectly, I didn't know how to thank you,

    God bless you...

Similar Threads

  1. Replies: 0
    Last Post: 05-12-2011, 07:04 PM
  2. File.class - Problem with SecurityManager
    By bhuvana_t in forum Advanced Java
    Replies: 0
    Last Post: 01-06-2011, 09:40 AM
  3. Replies: 1
    Last Post: 10-08-2010, 02:19 AM
  4. Replies: 8
    Last Post: 03-21-2009, 09:34 AM
  5. Replies: 0
    Last Post: 05-13-2008, 06:16 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •