jQuery in Action, 3rd edition
The moose likes Applets and the fly likes Applets / JDBC never the twain to meet? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "Applets / JDBC never the twain to meet?" Watch "Applets / JDBC never the twain to meet?" New topic

Applets / JDBC never the twain to meet?

stephen decke

Joined: Jan 26, 2007
Posts: 1
Hi all.

Let me start by writing that I am new to Java which might explain my question.

I am looking to write a java applet that reads from a Access database table located on the same server. The applet reads the table and creates a formated family tree. The applet can also write new entries into the table.

I know about security exceptions during runtime - but is such a thing possible? That is to say if I upload the html page with the applet on it - can the applet happily read and write to the database if I set up permissions and so forth at the start and then just leave it?

If such an apparently straight foward way of creating my family tree thing is not possible - what would be the next most likely solution?

I would appreciate any advice to point me in the right direction..

Thanks All.
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
Welcome to JavaRanch.

Access requires an ODBC connection to be set up (in order for the JDBC/ODBC bridge to work), and I'm fairly certain that you can't do that over a TCP/IP network, through firewalls and all.

It might work if all machines running the applet (and the server with the Access DB) are on the same network, though.
[ June 29, 2007: Message edited by: Ulf Dittmer ]
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33124

Welcome to JavaRanch!

While this question is on topic in both JDBC and Applets, I find people in the Applets forum know more about this stuff. I'm going to move your question there so you can get more responses.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Chad Clites
Ranch Hand

Joined: Aug 16, 2005
Posts: 134
The only way I know of doing so is to pass the information to a servlet on the server, and let the servlet do the work. There are a ton of examples on the 'net, but the one I followed was here:

Basically all this example does is takes a string, sends it to the servlet, and the servlet sends it back. I modified it to take a string as a parameter, query a database using that parameter, and return an arraylist to the applet. What ever you decide to return to the applet has to be serializable, otherwise it will not work properly.

I don't know if there is any more straight forward of a way to do it. IMHO, I would not want my applet to have direct access to my database anyway. I would want something on the server to make sure that the data was valid (not an attempt at SQL injection, etc), and just let the applet handle the display portion.
george zhao

Joined: Jul 02, 2006
Posts: 7
To Chad Clites:

I totally agree with you.

I am a newbie too.

Now I am involved in a Project which was designed to use applet in client side,and let servlet handle data communication.

But I am not clear why you said "What ever you decide to return to the applet has to be serializable, otherwise it will not work properly."Could you please explain more?

I also doubt about why people like to use applet embeded in HTML page, because it could code event-drived likely?

Frankly to say, My first java class is about applet, Although i am not good at it now, I just like it.

How can I enlarge my brain memory?
I agree. Here's the link: http://aspose.com/file-tools
subject: Applets / JDBC never the twain to meet?
It's not a secret anymore!