We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpIntegration › mysql and sqlibrary
Page Index Toggle Pages: 1
mysql and sqlibrary (Read 1478 times)
mysql and sqlibrary
Mar 10th, 2009, 7:21am
 
hi, i have used processing before but now im trying to my applet can query and modify a mysql database but seems to be something wrong, actually i dont know much about this, i used flash and php to do some before but now i guess processing can do all by itself..
i uploaded the applet and all the stuff that was in the export-folder, and check the index page where the applet shows me that cant connect to the db, but i dont know why
i use phpmyadmin from controlpanel, to check the tables on db but the applet couldn't create one (i can do that by a query on the phpmyadmin, so it's not a permission problem)
i hope you can help me (sorry about my english)
greetings from chile
Re: mysql and sqlibrary
Reply #1 - Mar 10th, 2009, 1:57pm
 
If the database is on a server different from the one serving the page where the applet lives (if that's an applet in the browser, of course), Java will refuse to connect unless the applet is signed.
See How to sign an applet for more info.
Re: mysql and sqlibrary
Reply #2 - Mar 10th, 2009, 3:58pm
 
Hi again, i didn't know about sign jars, but in the tutorial about it recomend to uncheck the "“Use multiple .jar files when exporting applets” option, i have this unchecked and still creates the core.jar file, well im using a library too (sqlibrary), besides i really dont know whats a terminal program, im using windows. sorry my noobness, greetings.
Re: mysql and sqlibrary
Reply #3 - Mar 10th, 2009, 4:41pm
 
See Bug 907 : Using multiple .jar files option in preferences doesn't work: the multiple jar export is intended when there are libraries.
I don't know if you need to sign all jars or only core. I think you need to sign all jars making access to the server, that would be your library jar then.

"terminal" in Windows: WinKey+R > Run dialog > type cmd and Enter and you will be there (that's the command line prompt).
Re: mysql and sqlibrary
Reply #4 - Mar 10th, 2009, 7:55pm
 
Hi, i used cmd of windows before but as the file.jar wasn't in the same folder that the bin java folder, the comands keytool and signer didn't work, in the same folder the signature process works very well, but im still having problems connecting the applet whit the db, i dont know if server refuse conection or the applet can't do it

ps: on processing _135 the export file is just one jar, but on 1.0 the libraries and core.jar are separated
Re: mysql and sqlibrary
Reply #5 - Mar 10th, 2009, 10:02pm
 
You can have details on applet by right-clicking on the Java icon in the tray notification area and choosing Open console. Error messages and exception stack traces are visible there.

I forgot I have installed the JDK, which isn't the case for all Processing users: I have the tools in the path, so no need to give full paths to them.

And the bug I point to explains why the behavior of 0135 have been abandoned (it is problematic with some libraries).
Re: mysql and sqlibrary
Reply #6 - Mar 11th, 2009, 10:06am
 
there are serveral problems with connecting to mysql from an applet:

1) the database might not be on the same domain as the applet, therefore you have to sign it to be able to connect (because of the java security). i see you are already wrestling with that.

1b) missed this: there might be a firewall inbetween that blocks the sql connection since it's on other ports than http.

2) for your applet to be able to connect you'd have to put the connection url, the user name and password into it. this information can be recovered from the .class/.jar and is therefore not secure!

3) your mysql server must be configuered to allow access from outside it's local domain, that means you have to configure it to allow connections from anywhere to be able to create, delete, read it's contents. that is a huge security risk!

to sum up: allthough it's possible you just should not connect to mysql from an applet. i recommend to go the flash route, tunneling thru a php file (although if done wrong that's insecure too).
Re: mysql and sqlibrary
Reply #7 - Mar 11th, 2009, 10:27am
 
fjen wrote on Mar 11th, 2009, 10:06am:
i recommend to go the flash route, tunneling thru a php file (although if done wrong that's insecure too).

What do you mean by "flash route" Need to use a Flash applet (I doubt it...) Or that's the way most Flash applets use

I agree with you, fjen, using a server-side script offering a secured and well defined Web service is much better. Of course, it adds another language (and system) to know in the mix. And as you point out, if not done correctly, it is an open door to any intrusion. See the classical hilarious xkcd's Exploits of a Mom...
Re: mysql and sqlibrary
Reply #8 - Mar 11th, 2009, 12:46pm
 
flash route was referring to scotchbrite mentioning having done that before with "flash and php". what i ment was

applet (via loadStrings) <---> php (or else) <---> mysql (or else)
Re: mysql and sqlibrary
Reply #9 - Mar 11th, 2009, 3:51pm
 
thanks all the answers, i guess the tunneling method it will be
Page Index Toggle Pages: 1