Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Database Connectivity in Applets 1

Status
Not open for further replies.

snnkmtt

Programmer
Oct 12, 2001
1
US
I have created an applet in Visual Cafe and when I run/debug it through Visual Cafe, it runs as expected. However, when I reference the java class with an HTML file and try and view that file with Internet Explorer, Internet Explorer shuts down.
Here is the code for connecting to an oracle database:

String DSN = "oracle";
String url = "jdbc dbc:" + DSN;

Connection conn;
Statement stmt;

try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
conn=DriverManager.getConnection(url,"xxx","pcs2");
stmt = conn.createStatement();
ResultSet rs;
.
.

How do I get my database connection to not only work when I run in Visual Cafe but also when I reference the class file with an HTML file? Thanks

 
Hi,

Applets can't connect to database, regardless of whether your database is at the client or server side. You will have to connect your applets to servlets to do so.

It is able to run in VisualCafe because, I presume, VisualCafe uses appletviewer. In appletviewer, applets are able to connect and access to a database because appletviewer assumes that your applet is "safe".

Regards,
Leon If you need additional help, you can email to me at zaoliang@hotmail.com I don't guaranty that I will be able to solve your problems but I will try my best :)
 
Actually, applets can connecto to a database. I have successfully connected to an Oracle DB using JDBC and an applet. I don't have the code available to me at this point, but it was an assignment in a database class a little over a year ago in school.
 
guys, no matter if you can or can not, for the sake of a structured and layered application development, don't ever consider connecting an applet directly to the database.

it is nice to know that such a thing is possible but you don't want to get into bad habit's :)
 
I agree with that statement. Actually, the applet that we wrote was painfully slow in retrieving and displaying data from the DB. I would post the link, but we password protected the applet, and I don't remember the user name, or the password!
 
Hi

Yes, I have managed to use an appplet to connect to a database from within a browser, but the data source was on my local machine so... I would really like to connect to a a remote database using an applet, but like Leon says, I think you will have to look at servlets (nightmare.)

For a while not I have been attempting to create a JAva interface for a remote database, and everytime I come into problems. Either you have to buy a commercial Sql driver, or I am bound by Java's Anal security policy ;).

Let me know how you get on..

Cheers..
email : oppenhiemer@supanet.com
 
You may need to change the security file in order to allow your applets to talk to a JDBC-ODBC DB either on the server.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top