Trouble with access database online

Hello everyone,

I created an applet that simply inserts data into an access database and then prints it out on the screen the sql insert statement.

I signed the applet so I can trust it so I wont get any security errors.

When I upload it to the site it shows the correct insert statement because the primary key auto increments and displays on the screen. I don't get any SQLException errors or SecurityException errors so I assume it is working.

When I download my database and look at it I dont see the data inserted into it. But when I see it in my browser it displays the insert statement with the primary key so I am really confused.

I tried in internet explorer and firefox and made sure I cleared my cache. Is there any possible thing that I missed as to why it gets the auto-increment primary key and doesnt get caught in the try catch but when I look at the database I don't see anything.

Any help would be great.

Thanks

[981 byte] By [synergy_guya] at [2007-11-27 10:36:24]
# 1

> Hello everyone,

>

> I created an applet that simply inserts data into an

> access database

Nope sorry, this won't be happening.

Besides the question of good or bad practice in connecting to a database directly from an applet (it's a bad practice) you cannot use Access for this because Access is not a database server.

If you really feel that you must connect to a database from an applet you must choose a database this is available as a service aka a database server.

cotton.ma at 2007-7-28 18:41:03 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2

Thanks for the advice but this does not really help my situation.

I could send data through a url and then program an asp page to handle the database stuff.

If you cant help me with doing the sql in the applet can you help me on sending data through a url in a java applet.

Thanks again

synergy_guya at 2007-7-28 18:41:03 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3

> Thanks for the advice but this does not really help

> my situation.

>

Well it does in that it is not "advice" it is a statement of fact and so it does help you in that you shouldn't waste time pursuing that.

The reason is, as you are already seeing, that when you update the Access database in your applet you are only actually updating the local copy (downloaded by the Applet) not the copy of the file on the server. So you can make all the changes you want but won't see them.

> I could send data through a url and then program an

> asp page to handle the database stuff.

Yes that would be a better way all around.

>

> If you cant help me with doing the sql in the applet

It's not that I can't help you. It's that is impossible. If you chose another database that was a server it would be possible.

I mean I can help but I cannot do the impossible.

> can you help me on sending data through a url in a

> java applet.

>

Yes. Use the HttpURLConnection class to do what you want. You can send it by GET (aka ASP Request.QueryString) or by POST (aka ASP Request.Form).

This tutorial shows you how http://java.sun.com/docs/books/tutorial/networking/urls/index.html

cotton.ma at 2007-7-28 18:41:03 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 4

Cool thanks I will check it out.

As far as the Request.Form("") I am very familiar with asp coding, haven't done much php though. Not that it matters for the moment

I will read this tutorial and then try it out.

Thanks Again

synergy_guya at 2007-7-28 18:41:03 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 5

> Cool thanks I will check it out.

>

> As far as the Request.Form("") I am very familiar

> with asp coding, haven't done much php though.

eh?

You said you wanted to do this in ASP so i gave you the ASP methods. PHP would be different of course.

It doesn't matter though because the basic ideas are the same.

cotton.ma at 2007-7-28 18:41:03 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 6

hello I have the following code here

try {

URL url = new URL("http://torrent.somee.com/java/database/data.asp");

URLConnection urlConn = url.openConnection(Proxy.NO_PROXY);

urlConn.setDoOutput(true);

urlConn.setUseCaches(false);

showStatus("DONE NOW");

} catch(MalformedURLException e) {

showStatus("MalformedURLException " + e);

} catch(IOException e) {

showStatus("IOException " + e);

} catch (SecurityException e) {

showStatus("SecurityException " + e);

} catch (IllegalArgumentException e) {

showStatus("IllegalArgumentException " + e);

} catch (UnsupportedOperationException e) {

showStatus("UnsupportedOperationException " + e);

}

I basically just want this code to call the page behind the scenes. I already tested my link above in the url object and it works without error and inserts data into the database. However in the java applet it doesn't.

I tried

url.openConnection(Proxy.NO_PROXY) & url.openConnection()

but these dont work. I am not sure if this is the source of my problems but any help would be great.

Thanks

synergy_guya at 2007-7-28 18:41:03 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 7

I also forgot to mention that none of these catch blocks get caught when I run this and it doesnt show the "DONE" either

synergy_guya at 2007-7-28 18:41:03 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 8

Get and read the connections input stream and see what happens.

cotton.ma at 2007-7-28 18:41:03 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 9

Thanks it works

synergy_guya at 2007-7-28 18:41:03 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 10

> Thanks it works

The problem was that despite the name openConnection does not actually mean that the request has actually been sent. This is so you can set headers as needed etc.

But then you need to get the URLConnection to actually send the request, and asking for the response is one way to do that.

cotton.ma at 2007-7-28 18:41:03 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...