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 › Connecting to mysql
Page Index Toggle Pages: 1
Connecting to mysql (Read 2406 times)
Connecting to mysql
Mar 18th, 2007, 7:37pm
 
Hi all, first post of probably many...

I'm attempting to pull some images out of a mysql database but I'm having trouble getting my head round what info I need. I'm using this code...

   // this example assumes that you are running the
   // mysql server locally (on "localhost").

   String user     = "I'M SURE I'VE GOT THIS RIGHT";
   String pass     = "I'M SURE I'VE GOT THIS RIGHT";

   // name of the database to use
   String database = "I'M SURE I'VE GOT THIS RIGHT";

   // name of the table that will be created
   String table    = "testtable";

   // connect to database of server "localhost"
   msql = new MySQL( "195.62.28.230", database, user, pass, this );

Now I've checked with my host and I can access it externally. They told me this:

'Yes, we do allow external access to the MySQL databases, you will need to enter your ISP IP address in the “Access Hosts:” field.

Server IP address: 195.62.28.230
MySQL Port: 3306'

I'm not sure what to do with the port number but I've been diggin around and I think I need it. Also I'm not sure about the ISP IP address bit, is that the same as the server ip address they have given me? It sounds to me like they want me to add that address as an access host in Cpanel but isn't that just the same as using localhost?! Either way, my code will not connect to the database. I get this error message:

MySQL.connect(): Could not connect to the database ( jdbc:mysql://195.62.28.230/MY_DATABASE_NAME ).

java.sql.SQLException: Access denied for user 'MY_USERNAME'@'%' to database 'MY_DATABASE_NAME'

at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2851)

Obviously these usernames etc are all replaced.

Thanks in advance for any pointers you can give me.
Re: Connecting to mysql
Reply #1 - Mar 19th, 2007, 7:09am
 
have you tried to connect to the database from a shell / terminal? what system are you on?
the command to try would be:

mysql -h 195.62.28.230 -P 3306 -u <YOUR_USER> -p -d <YOUR_DATABASE>

if this connects, the connection is ok. obviously.

you are running your sketch inside Processing not as an exported applet, right?

your server seems to be open to external access, otherwise you'd get a "is not allowed to connect to this MySQL server" error. the error you are getting sounds more like a problem with the login. your user-name might not be allowed to connect from any host.

i think the best thing is to ask your hoster about these problems, they know ...

F
Re: Connecting to mysql
Reply #2 - Mar 19th, 2007, 9:00pm
 
Shell or terminal? Sorry, that means nothin to me... this is my first week with databases and my first 3 days with processing! My OS is XPsp2(if that's what you mean), and yeah I'm running in processing.

Cheers for the advice, I really appreciate it. I'll get on to the host... it felt a bit cheeky going to them with a processing question but now I can disguise it as a 'why wont my username connect externally' question. Nice.

One more thing, what does this bit @'%' mean in my error message?

Access denied for user 'MY_USERNAME'@'%' to database 'MY_DATABASE_NAME'

Cheers again.
Re: Connecting to mysql
Reply #3 - Mar 19th, 2007, 9:35pm
 
it's a wildcard. it should mean "connection from anywhere" ... but that on the other hand does not mean your username actually has that setting. the response just says a user connecting from "somewhere" with that username can't get access. at least that's how i read it .. good luck.

here's more:
http://dev.mysql.com/doc/refman/4.1/en/grant.html

you can try and install some mysql administration tool on your machine and connect to your server from there. ... but i don't have any idea what's a good tool for XP to do that, you might want to google some.

F
Re: Connecting to mysql
Reply #4 - Mar 19th, 2007, 10:37pm
 
You are a dude.
Re: Connecting to mysql
Reply #5 - Mar 27th, 2007, 8:21pm
 
Hey....dude. This suddenly started working for me for no reason. Which is good, although I have moved to mobile processing and the same code doesn't work there. This is my brand spanking new error message. Is mobile processing not capable of this?

C:/Documents and Settings/James/My Documents/MobileProcessing/db_connedct_test/midlet/db_connedct_test.java:43:12:4
3:67: Semantic Error: No applicable overload was found for a constructor with signature "MySQL(java.lang.String, java.lang.String, java.lang.String, java.lang.String, db_connedct_test)" in type "de.bezier.mysql.MySQL". Perhaps you wanted the overloaded version "MySQL(java.lang.String $1, java.lang.String $2, java.lang.String $3, java.lang.String $4, processing.core.PApplet $5);" instead?
Re: Connecting to mysql
Reply #6 - Mar 28th, 2007, 7:11am
 
no, i don't think it's possible to run it on mobiles ... although i never tried.

best,
F
Page Index Toggle Pages: 1