COnnect an applet to a database...

I have simple java program connecting to my mircosoft sql database... WHen i compile and run it i have to include the paths to the .lib files. which is grand. that works.

The applet that i have designed only needs to be compiled and then opened in an internet browser...

I need to connect the applet to my database but how do i do this when the java program needs to be compiled and run whereas the applet only needs to be compiled?

Thanks

Ollie

[478 byte] By [OllieMahera] at [2007-11-27 1:44:52]
# 1

In general, the best way to connect to a database is

by a JDBC connector. This is a library, written by

database vendor like MySQL, Oracle, Microsoft, etc..

In your java program, you should use the JDBC standard

API so your code will be indipendent from a specific

driver and, the most important, from native library.

Hope this helps.

CanapaGa at 2007-7-12 1:04:32 > top of Java-index,Desktop,Core GUI APIs...
# 2

Depending on what do you need...

do you need just a local database to store some data... you could use a out-of-the-box database like derby, integrated in Java 6... but you need to store the database file on the local machine, where the applet is invoked... this would be possible if you sign the applet due to access restricitons.

do you need a remote database connection to a server (client server, applet:client, mysql/whatever:server) you can only connect to the server where the applet comes from, due to access restrictions, otherwise signing would be helpful too). You should be able to connect the standard java-way (JDBC, etc.) in an applet too...

For both cases it would be bad idea to use hibernate or spring or some other framework/ORM because these have lots of java code shipping with and the applet would grow fast... bad for the transfer.

Java 6 is shipped with an ORM ( as I know so far ) so you haven't have to ship it with.

Greets.

SpecialAgenta at 2007-7-12 1:04:32 > top of Java-index,Desktop,Core GUI APIs...