Results 1 to 11 of 11

Thread: Database driver problems from my applet's jar file help

  1. #1
    Old school, like an old fool. Flying Mullet's Avatar
    Join Date
    Apr 2003
    Location
    Napping in a peach tree.
    Posts
    19,185
    Articles
    6
    Blog Entries
    7
    Contributions
    • Former Administrator
    • Former Cid's Knight
    • Former Senior Site Staff

    Default Database driver problems from my applet's jar file help

    Yeah, I know that only a small subset of the population here will be able to offer any help, but I'm bald from pulling my hair out and need all the help I can get.

    I'm trying to set up an applet that will talk to a MySQL database. I have no problem connecting to the database as I'm developing the code ("un-jarred"), but when I create a jar file of my code to test through a web browser, I cannot connect to the database due to the usual ClassNotFoundException. I have included mysql-connector-java-3.1.12-bin.jar (the current driver) in the applet jar, but I don't know if I'm supposed to supply some info through an attribute to the applet tag to let it know that the jar contains the driver it needs or if I have to call the driver differently in my code.

    Any ideas?
    Figaro Castle

  2. #2

    Default

    conn = DriverManager.getConnection("jdbc:mysql://" + hostname + "/" + database + "?useUnicode=true&characterEncoding=Big5", login, password);

    It has been about a year since I have done anything like this. In fact, I don't think I have ever done it with an applet - only an application. I am poop.

    [edit] Oh, I reread the question. No, to my knowlage there is not attribute needed in the applet tag. I can look into it some more. You use websphere, correct? are you importing using the import command attop your program?

    Double check your archive poperty in your applet tag??

    [edit 2]try this link: http://www.stardeveloper.com/article....html?tid=1647 It looks like this guy may have had similar issues, and his approach seems a lil haphazard - but I have nothing to test it on atm. Enjoy!

    Bipper
    Last edited by bipper; 05-31-2006 at 07:35 PM.

  3. #3
    Old school, like an old fool. Flying Mullet's Avatar
    Join Date
    Apr 2003
    Location
    Napping in a peach tree.
    Posts
    19,185
    Articles
    6
    Blog Entries
    7
    Contributions
    • Former Administrator
    • Former Cid's Knight
    • Former Senior Site Staff

    Default

    I just got it figured out (with some help from sun's java forums.

    Turns out that jars in jars are a very bad idea, as you have to write your own custom class loader to navigate the "multi-leveled" jars and find what you want.

    As they say, the easiest solution is the best, and it was in this case too. All I have to do is include the extra jar file for the db driver in the applet tag and it works like a charm:

    <APPLET CODE="main.TheGameApplet" archive="signedthisisthegame.jar, mysql-connector-java-3.1.12-bin.jar" WIDTH="1000" HEIGHT="600"></APPLET>
    Figaro Castle

  4. #4

    Default

    tehsex. congrats mulley

  5. #5
    Ominous Wanderer Tech Admin Samuraid's Avatar
    Join Date
    Oct 2001
    Posts
    5,522

    Default

    Just as a sidenote, is connecting to a database through a jar file really secure? Because if you do put something like that on the web, I'm going to be forced to download and unzip all your jars, and decompile the classes back to the source to see if the database is able to be hacked.

  6. #6

    Default

    not really - thus another footnote on my hate for java. Feel the hate

  7. #7
    ORANGE Dr Unne's Avatar
    Join Date
    Dec 1999
    Posts
    7,394
    Articles
    1
    Contributions
    • Former Administrator
    • Former Developer
    • Former Tech Admin

    Default

    Quote Originally Posted by Samuraid
    Just as a sidenote, is connecting to a database through a jar file really secure? Because if you do put something like that on the web, I'm going to be forced to download and unzip all your jars, and decompile the classes back to the source to see if the database is able to be hacked.
    I was going to ask this, but I didn't want to hijack the thread. I can't see how it's at all secure. Can you encrypt a jar file?

    A Java applet has to be run client-side, so you're guaranteed to be sending the scripts to the client. I've had to decompile bytecode back into Java before and it's fairly trivial (good thing it's possible, I almost lost a group assignment in a robotics course in college).

    You could have a Java daemon sitting on the server that sends data out to clients. Then you could at least be sure to control the nature of the data that's being sent and avoid letting any client in the world talk to your SQL server, and since the daemon is running server-side you can keep your SQL login scripts out of DocumentRoot so no one can get at it. But then you have to rely on the security of your own daemon not to go whoring out your database to people. I'd rather rely on the security of Apache than on anything I write myself.

  8. #8

    Default

    I actually relly straight on files structure modes for my security. It's what universal hackers want anyways. Comp the file struct, and whammo - who cares what precautions you tried to take (to a point ) Straight XML writing, FS management, and user management for me! kthx Java's own applet security structure prevenets this from being any real use.

    Bipper

  9. #9
    Old school, like an old fool. Flying Mullet's Avatar
    Join Date
    Apr 2003
    Location
    Napping in a peach tree.
    Posts
    19,185
    Articles
    6
    Blog Entries
    7
    Contributions
    • Former Administrator
    • Former Cid's Knight
    • Former Senior Site Staff

    Default

    Yes, I've actually been wrestling with these thoughts myself for a while now. It all started as a way to practice applets and learn AWT/Swing. Once I realized the security risks I decided to see if I could find out a way to prevent "malicious use" of the database but since it's client side code it's near impossible to prevent.

    Nothing like a near impossible challenge, eh?
    Figaro Castle

  10. #10

    Default

    I went through the same thing. I released a 2d mmo named Nhaven for about 6 months, but the holes in security were far too many. I then dropped Java and began to loathe it from there on. That is when I became my own Cvangelist and have been studying the least hackable methods to save server side data while dealing with a Server/client relationship. From what I have found - databases do the oposite of help. Unfortunatly, coorps and comunities are lazy, and look for the easy way out. this is going to lead to a plethora of hack crimes and complete information anarchy in the future imo. But whatever ...

    Its all about games with me.

    bipper

  11. #11
    Ominous Wanderer Tech Admin Samuraid's Avatar
    Join Date
    Oct 2001
    Posts
    5,522

    Default

    A JAR file is simply a PK zip file. Even if you found some way to password protect it, breaking that protection would be relatively straightforward.

Posting Permissions

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