JDBC and Applets

Hi!

I want to access to a DB via an applet.

Should I use JDBC (with a 100%-pure-JAVA-Driver) to connect to this DB or

should I get the data from an server-side-application (for example a JSP), returning the data in a structured way (XML, CSV, ...)

If I use JDBC, will the Applet connect to the webserver, which connects to the db-server or will the applet directly access to the db-server, what means that the db-server's port must not be protected by an firewall ?

What problems may I run into, using JDBC with Applets ?

Thanks and Best Regards,

fredy

[616 byte] By [mrVisual] at [2007-9-26 1:25:10]
# 1
Hi,I think the best solution for you is to use the Rmi-Jdbc bridge. Take a look at http://java.sun.com/products/jdbc/faq.html#5 and for download http://dyade.inrialpes.fr/mediation/download/Hope this helps,Kurt.
leukbr at 2007-6-29 1:06:19 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2
You can not use applets directly to access database.You have to use some server side program like a servlet. You can write a class which the applet accesses and that class then accesses the servlet. If you search google for applet to servlet you will get the code.
aparna_chitragar at 2007-6-29 1:06:19 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3

<If I use JDBC, will the Applet connect to the webserver, which connects to the db-server or will the applet directly access to the db-server, what means that the db-server's port must not be protected by an firewall ?What problems may I run into, using JDBC with Applets ? >

Hi fredy,

You can access the database directly from applet , but not the database from the client machine. The applet executes in a sandbox which has some restrictions like it cannot access file system, database or native code. In other words it has few restricted resources to use. This is all to avoid malicious programs to harm the client. However an applet can very well connect to the database of the machine from which it has been downloaded. It cannot connect to any other URL. But there is again a restriction on the type of driver you use. Type 1 and Type 2 drivers partially or fully depend on the native code so it is not possible to connect to the remote database using Type 1 or 2 drivers. So you are left with type 3 or 4 drivers which are 100% pure java drivers and donot depend on any client side native code.

In fact some type 3 drivers are especially helpful for direct database access for applets, as they provide encryption of data. As you might be knowing that type 3 drivers have 2 parts one is the 100% pure java part which is sent as class file with the applet to facilitate making the connection and other is the server part of the driver which connects to the database using native code of the server. Thus the 2 parts can encrypt and decrypt the information exchanged.

I think this information can help you.

Harpreet

harpreet_hira at 2007-6-29 1:06:19 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...