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 processing with mysql dabase
Page Index Toggle Pages: 1
connecting processing with mysql dabase (Read 1227 times)
connecting processing with mysql dabase
Jul 23rd, 2008, 11:02am
 
4

hello , i want to make a visualization tool from a database in my hosting server  made in mysql

i want to be able to connect to my database in my  webserver from my processing sketch.............
my hosting  server  allows me to connect to my database from my computer, in telnet i need to connect first to the ftpserver , then i can
connect to the database..................................


how  can connect to my database from my computer from a processing sketch?

im using the mysql library in processing
i was checking the example that comes with the library , but the example assumes that you are running the  mysql server
locally !!!!

how about if i dont have the server installed in my computer, but i want to use the database from my hosting server?
how can i connect to the database from a sketch?

i have both windows and macosx? does it works on both? any idea?
is there is a way of connecting to the ftpserver then connect to the database?

thanks
Re: connecting processing with mysql dabase
Reply #1 - Jul 23rd, 2008, 11:39am
 
By the sounds of it, I don't think you'll be able to connect directly from processing, since even when you do it by hand, the access to the database is from the server itself, not actually from your computer.

You might be able to get around this by having some PHP that does the database work, and get your processing sketch to read the data via the PHP files.
Re: connecting processing with mysql dabase
Reply #2 - Aug 26th, 2008, 3:42am
 
Are you saying me i need to read php files? i didnt understand very well your question. Did you see mysql library? they say i can connect remotely:
"- check the connection from where you are running the sketch with this command:
shell>  mysql -h <host> -u <user> -p
where <host> is the host running the database and <user> is your username.
you will be promted for a password. if the connection attempt is successfull you
will see something like: "Welcome to the MySQL monitor. ... ". the command
mysql> QUIT
will quit the mysql-monitor. "

i can connect to the my data base from terminal or telnet first connecting to the web server my database is . mysql library comes with an example but it assumes you are connecting as localhost. but how about if i want to connect remotely?i think maybe i need connect to the web server  first then connect to the msql database as when i do from the terminal.

So my question is : how can i connect to ftp server from processing?

thanks


punchik
Re: connecting processing with mysql dabase
Reply #3 - Aug 26th, 2008, 6:13am
 
hi, i was trying with the library sftp, but no luck i can connect to the ftp server but when it tries to connect to the mysql server i get an error message:
Attempting to connect.
Logging in.
Connected, session started.
SQL.connect(): Could not connect to the database ( jdbc:mysql://zotaplex.zotaplex.net/nusixride ).

java.sql.SQLException: Access denied for user 'zotaplex'@'200.37.161.41' (using password: YES)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2975)


Do anybody have any idea?


here is the code:



import de.bezier.mysql.*;
import sftp.*;

Sftp sftp;

MySQL msql;
   // replace --username--, --password-- with your mysql-account.
   //
   String user     = "zotaplex";
   String pass     = "comaku";

   // name of the database to use
   //
   String database = "nusixride";

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

void setup()
{
   size( 100, 100 );
   
     sftp = new Sftp("pangosus.dreamhost.com","zotaplex", true);
  sftp.setPassword("3fasfsCM");
 sftp.start(); // start the thread

 noLoop();

}

void draw()
{
   // i know this is not really a visual sketch ...
}
void mousePressed() {

  msql = new MySQL( "zotaplex.zotaplex.net", database, user, pass, this );
   
   if ( msql.connect() )
   {  
       // create a table with an id and a word
       //
       msql.execute( "CREATE TABLE IF NOT EXISTS " + table + " ("+
                         "id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,"+
                         "word VARCHAR( 255 )"+
                     ")"
                   );
                 
   }
   else
   {

   }
}

Page Index Toggle Pages: 1