Database location in Applet

Hi guys

I'm not an expert in java, so sorry if i'm doing a simple question ;)

I have a java applet that use the postgres jar file to connect to a database, my question is: how can the applet know the database location? if it was a static location would be embuted inside code, but could be any address and authentication...

I hope that information is enougth...

Thanks,

Paulo

[414 byte] By [Paulo_LRa] at [2007-11-27 6:43:07]
# 1
The PostgreSQL database is connected to with the connection URL. http://dev2dev.bea.com/pub/a/2005/05/intro_to_postgresql.html
dvohra09a at 2007-7-12 18:13:38 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2

I dont know if it was you that didnt understand my question or me your answer ;)

But the problem is that the applet will run in a https made in java, and could be running in different configurations(IP,Port,Username db,Password db). If it wasn't a applet a local conf file was enougth.

The users of https/applet just know the IP and Port of https, how can the applet know here is the location of database (IP,PORT,username, password). With cookies?

Tks

Paulo_LRa at 2007-7-12 18:13:38 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3

I don't understand your question either.

There is only one database, right? And it is located on your server, the same server where the applet was downloaded from? Then the applet can easily find out the URL of that server, and you can hard-code the other connection parameters or make them parameters in your HTML.

Or do you have the idea that the users are each going to be updating different databases somehow?

DrClapa at 2007-7-12 18:13:38 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 4

Well, you are way ahead of me.

I have written a class java that reads the directory of files, then reads each individual file looking at file sizes and different records inside the files. It works fine until I make it an applet. Then it gets a java security manager error.

When I read about applets, it seams that they cannot read files on a server, i. e. you have to be a servlet. But, here I see you have done it.

I am stuck now, because not only do I need to read files, but display them back.And it appears that servlets cannot display stuff.

So basically I feal screwed.

Any light you can shed on this I would appreciate.

(these are not database files, but regular DOS files, like html, java, etc)

Thank you.

jagossagea at 2007-7-12 18:13:38 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 5
What's wrong with just writing a plain old Java application and running it on any machine you need to run it on? Why do you need an applet?
DrClapa at 2007-7-12 18:13:38 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 6
I need the software to be used from any place(internet). It's like a users management utility of a system,to have online users registation and modification....
Paulo_LRa at 2007-7-12 18:13:38 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 7

> I need the software to be used from any

> place(internet). It's like a users management utility

> of a system,to have online users registation and

> modification....

Okay. Do I understand you correctly that you want the users to be able to update files that are on your server? I am just guessing here because your description of your requirements is really bad. First there was a database, now there are files, and something needs to both read them and display them back (I don't know what's the difference between those two things).

Generally if you want people all over the place to connect to your server and update files there, you write a server application. Applets are not the right tool for that and neither is an application.

DrClapa at 2007-7-12 18:13:38 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 8
Not to mention a significant number of security issues with doing something like that.
jschella at 2007-7-12 18:13:38 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 9

It's to interact with a postgres database, not to files.

The problem is the applet have to know the location and authentication of database...

I just talked about files, because i think could be one solution the html write a cookie and the applet gona read it,of course encrypted...

Tks and sorry for my poor explanations

Paulo_LRa at 2007-7-12 18:13:38 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 10

Paulo,

In order to access a database from an applet you usually need to make the applet a signed applet and you need to download the JDBC driver together with the applet.

There is plenty of information on the Internet about how to make signed applets and how to download JAR archives together with your applet.

Alternatively, you could use JSP (Java ServerPages) and/or servlets.

The JSTL (JSP standard taglib library) has a set of "SQL" tags specifically for allowing a JSP to interact with a database.

Somewhere, some piece of software needs to know the connection details for the database. There are several ways to do this. If you use a servlet, then the servlet needs to know. Or you could use a properties file downloaded with your applet, or you could do it the most popular way and use PHP (instead of java ;-), or an application server.

Good Luck,

Avi.

Message was edited by:

abramia

abramiaa at 2007-7-12 18:13:38 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 11
Hi...Let your applet connect to a servlet on your server, during init() method,It will get the database URL from servlet, and will connect to database using tht URL. sudhir http://www.jyog.com
Sudhir_nimavata at 2007-7-12 18:13:38 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 12
... Or you could use a properties file downloaded with your applet, ...That's exacly that i want....Put a file in a specific location,and the applet in init goes and read that file ...What's the best way to do this?Sorry and tks for the help
Paulo_LRa at 2007-7-12 18:13:38 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...