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.
Pages: 1 2 
MySQL library (Read 6408 times)
MySQL library
May 7th, 2005, 7:04pm
 
http://www.bezier.de/mysql/

needed this for a project .. so in case someone want's to give it a try or finds it useful. it's a half-an-afternoon project, so i'm sure there are some issues ... let me know.

(source and build-file is included for people interested in getting started with building your own libraries ...)

F

( oh, i'm gonna move all my processing stuff over to my geekie bezier.de domain over the next couple of weeks ... )
Re: MySQL library
Reply #1 - May 8th, 2005, 1:21am
 
You're online.
http://processing.org/reference/libraries/
Re: MySQL library
Reply #2 - May 10th, 2005, 8:39pm
 
for connecting to a remote host, ie:

"mysql.somedomain.org"

don't you need to establish an SSH connection first? Or am I missing something...

Re: MySQL library
Reply #3 - May 11th, 2005, 1:00am
 
well, to be honest i only used it locally so far ... i'm not the super-geek in these things (ssh & java), so let me know if you find out how to do this.

( applets using the lib will 100% sure run into security restrictions with java's sandbox, only allowing you to connect to the same domain the applet came from )

F

someone here know about ssh-tunnels and java or mysql? is it possible to set up a ssh-tunnel (from java?) to automatically redirect the mysql-connection to the remote host? any pointers welcome ...
Re: MySQL library
Reply #4 - May 11th, 2005, 8:25pm
 
fjen,

I am looking into this today..maybe I'll find a good way to do this today (?) I will let you know..
Re: MySQL library
Reply #5 - May 11th, 2005, 9:06pm
 
great, i've sent you a goodie via mail. see if that works better ...
looking forward to hear from you.

F
Re: MySQL library
Reply #6 - May 12th, 2005, 9:25am
 
I found a solution for connecting to a remote host (at least on mac os 10.3.9). There was a problem with the mysql-connector that was installed on my system.

I'll write up a more descriptive fix to the problem that others users might find tomorrow, and let you know my experiene with remote connection via windows machines as well.

but I got it working!
Re: MySQL library
Reply #7 - May 12th, 2005, 2:02pm
 
wow. super you're gold!
F
Re: MySQL library
Reply #8 - May 12th, 2005, 7:28pm
 
To connect remotely to another database, I had to download the latest version of the mysql Connector/J from here:

http://dev.mysql.com/downloads/connector/j/3.1.html

and replace the older version from my:

Library/Java/Extensions/

so now I can connect and retrive results (but not yet as running as an applet,still need to figure this out)

But this is a good first step for other Mac users who are having problems connecting remotely.
Re: MySQL library
Reply #9 - May 12th, 2005, 9:04pm
 
this is not needed with the new version (002) ... it already includes that specific driver ( 3.1 ). note that it's not a good idea to have the driver in the extensions since it might conflict with a newer version later ...

it will soon be available from my site, once we're done with testing. i'll let you know here.


F
Re: MySQL library
Reply #10 - May 13th, 2005, 1:08am
 
ok. i've just uploaded a new version (002) and added some notes on applets, remote and local servers ...

http://bezier.de/mysql/

F
Re: MySQL library and classes
Reply #11 - May 26th, 2005, 12:21am
 
Well, this one has me stumped..I figured out the MySQL library, figured out its best not to do the querying within the draw() method, etc.

So I'm trying to create a class SQL that has all my queries embedded within methods. What I have so far is this:

Code:

import de.bezier.mysql.*;

MySQL msql;
sql sqlFuncs;


// created 2005-05-10 by fjenett
// updated 2005-05-12 by fjenett

void setup()
{
size(100,100);
sqlFuncs = new sql(user,password,database,host);
numChapters = sqlFuncs.selectCount();
println(numChapters);

}

class sql {
String user = "root";
String pass = "projecto";
String database = "solaris";
String table = "images";
String host = "localhost";

sql( "localhost", "solaris", "root", "projecto", this)
{
mysql = new MySQL( host, db, username, password, this);
if ( !mysql.connect() )
println("not connected");
}

int selectCount()
{
mysql.query( "SELECT COUNT(*) FROM " + table );
return mysql.getInt("COUNT(*)");
}
}


Does anybody (fjen as well?) have any ideas what I'm doing wrong, or what the library doesn't like?

thanks for all of your help...
Re: MySQL library
Reply #12 - May 26th, 2005, 6:28am
 
tim, a couple of things:

1. your MySQL instance is called msql, not mysql.

2. if I'm not mistaken "mysql.getInt("COUNT(*)");" will fail because "COUNT(*)" is not an id in the query result. according to this page you can declare it like this:

Code:
SELECT COUNT (*) as "number" FROM tablename 



after which you should be able to do mysql.getInt("number"). does that make sense? mind you, I haven't tried it and I am far from an expert on SQL...
Re: MySQL library
Reply #13 - May 27th, 2005, 3:26pm
 
sorry, i'm on vacation ...

Code:

import de.bezier.mysql.*;

MySQL mysql;
sql sqlFuncs;

void setup()
{
 size(100,100);
 sqlFuncs = new sql(this);
 int numChapters = sqlFuncs.selectCount();
 println(numChapters);
 
}

class sql {
String user = "root";
String pass = "----";
String database = "----";
String table = "----";
String host = "localhost";

// you can't pass values the way you did ...
//
/* please take the time to lookup and learn about classes, constructors and variable scope. */
 sql(PApplet _p)
 {
    mysql = new MySQL( host, database, user, pass, _p);
    if ( !mysql.connect() )
   println("not connected");
 }  

 int selectCount()
 {
mysql.query( "SELECT COUNT(*) FROM " + table );
mysql.next();  // you need to jump to the first result here!
return mysql.getInt("COUNT(*)");
 }
}


F


http://www.shiffman.net/itp/classes/ICM/week2/index.html
http://www.shiffman.net/itp/classes/ICM/week5/index.html
Re: MySQL library
Reply #14 - Jun 1st, 2005, 9:11pm
 
Hi. Heres a quick and random question. the mysql library has mysql.getTimestamp("date"); but in the reference I dont see anyway to get this data in. Proccessing reference library only shows me functions for date objects, like hour() etc.

How can I get the full datetime 'string' from mysql, and what do I use to parse it?

Thanks,
Pages: 1 2