Java Applet - linking to my MS Access Database

have moderate skill level with java.
i have looked through the experts xchange for anything similar to my simple problem but they
all seem to be more advanced and confusing.

any help would be GREAT, thanks in advance!

enclose my simple code:

public class AppletDBaseTester extends JApplet
{
     static JLabel Header;
       static JButton EnterButton;
     public void init()
     {
     Header = new JLabel("link applet to dbase");
     EnterButton = new JButton("try");
     EnterButton.addActionListener(new DisplayResults());
     Container c = getContentPane();
     c.setLayout(new GridLayout(0,1));
     c.add(Header);
     c.add(EnterButton);
        }
     public static void DBase()
     {
     String URL = "jdbc:odbc:AppletTester";
     String username = "";
     String password = "";
     String[] EraseDBaseSQL =
     {     "Drop Table RoomTable"
     };
     try
     {
     Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
     }
     catch (Exception e)
     {
     System.out.println("Failed to load JDBC/ODBC driver.");
     return;
     }
     Statement stmt = null;
     Connection con=null;
     try
     {
     con = DriverManager.getConnection (URL,username,password);
     stmt = con.createStatement();
     }
     catch (Exception e)
     {
     System.err.println("problems connecting to "+URL);
     }
     try
     {
     for (int i=0; i<EraseDBaseSQL.length; i++)
     {
     stmt.execute(EraseDBaseSQL[i]);
     }
     stmt.close();
        con.close();
     }
     catch (Exception e)
     {
     e.printStackTrace(System.out);
     System.err.println(EraseDBaseSQL);
     System.err.println("problems with SQL sent to "+URL+ ": "+e.getMessage());
     }
    }
}

class DisplayResults implements ActionListener
{
   public void actionPerformed(ActionEvent e)
   {
   AppletDBaseTester.DBase();
   }
}



i get the "Failed to load JDBC/ODBC driver" error


any ideas or am i going for the wrong idea... if someone has a few lines to help me :) thanks

Gareth
PowerMaxUKAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

girionisCommented:
 Can you change this:

  System.out.println("Failed to load JDBC/ODBC driver.");

  to this:

  System.out.println("Failed to load JDBC/ODBC driver." + e);

  and let us know of the output?
0
PowerMaxUKAuthor Commented:
returned following to console:

Failed to load JDBC/ODBC driver.java.security.AccessControlException: access den
ied (java.lang.RuntimePermission accessClassInPackage.sun.jdbc.odbc)


Gareth
0
bkrahmerCommented:
I believe that to let applets have access to an ODBC data source, you'd either have to configure no (or low) security at the client's VM, or digitally sign your applet.

brian
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

RayGunCommented:

There are four different kind of drivers for JDBC, the JDBC/ODBC is a type 1 driver and as mentioned is restricted to signed applets. You may want to go to microsofts netpages and download type 4 driver wich is faster driver. You should generally be aware of the restrictions that an applet has when using JDBC, go here for a quick overview: http://www.sybase.com/detail/1,6904,1000696,00.html

0
girionisCommented:
 As mentioned above you will either need to sign your appelt or give permissions to it manually. If you want to do it manually just edit the java.policy file and add the RuntimePermission. If you want to sign the applet look here:

  http://www.ddj.com/articles/1999/9902/
  http://java.sun.com/security/signExample/index.html
0
PowerMaxUKAuthor Commented:
the idea is so i can run my webpage/applet on a network pc. so i dont know if i can but i dont really want to go throught the process of setting permissions on everyones java.policy file. im sure that would take a long time as there is many computers. what would the line be to set the permissions in the policy file?
i want to do it on mine to make sure it all works ok for a start.
then what does everyone suggest i do? would there just be a few lines to add to my code that will sign it without mass effort for every user?

many mnay mnay thanks

Gareth
0
girionisCommented:
 Then you will need to sign the applet I am afraid. You only have to sign it once and then it will eb done automatically on every computer that tries to access it.

  And I'd also suggest you use type 4 drivers since type 1 (that is JDBC/ODBC bridge) require every single user to have a datasource configured on their computer, therefore you will have to manualyl configure the database source on every client machine.
0
PowerMaxUKAuthor Commented:
ok so i get type 4 drivers and i sign the applet.

i know there are links above but any clue where to get the driver from or even a slightly less complicated example of signing an applet... i will go look myself, being lazy.

any help would be appriciated tho :)
thanks
G
0
girionisCommented:
 You can get the drivers from here:

  http://industry.java.sun.com/products/jdbc/drivers

  each database has different drivers.

  Signign applets:

  http://www.experts-exchange.com/Programming/Programming_Languages/Java/Q_20060040.html
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
PowerMaxUKAuthor Commented:
i tried that drivers page, it came up with 2 driver locations both the same

http://www.bcs-corp.com/download.shtml

and the driver isnt there :/

will driver 3 be ok?
0
girionisCommented:
 Yes it will probably be fine. If in doubt read the documentation.
0
PowerMaxUKAuthor Commented:
ok, thanks for all the help... think its well on the way to running i hope :) have enough info now! :)

thanks all

gerionis i will accept one of your answers... does it matter which one?

thanks

Gareth
0
girionisCommented:
 No it doesn't but I suggest you accept a relevant one so other people might be helepd as well :-)
0
PowerMaxUKAuthor Commented:
Thanks very much!

gareth
0
girionisCommented:
 Thank you :-)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.