MySQL constructor and "this"
in
Contributed Library Questions
•
1 year ago
Hello!
I used SQLibrary and I tried a ready made example which is shown at the end of the post..
What I want to do is to put this code into a separate class but I always get MySQL constructor undefined..
I suspect that the "thing" inside the msql = new MySQL( this, "localhost", database, user, pass ) causes the error but I cannot really tell..
Is there any way to replace the "thing" with something else(assuming that his is what's causing the exception..).
Thanks guys!
import de.bezier.data.sql.*;
MySQL msql;
void setup()
{
size( 100, 100 );
// this example assumes that you are running the
// mysql server locally (on "localhost").
//
// replace --username--, --password-- with your mysql-account.
//
String user = "root";
String pass = "admin";
// name of the database to use
String database = "bildwelt";
// connect to database of server "localhost"
msql = new MySQL( this, "localhost", database, user, pass );
if ( msql.connect() )
{
msql.query( "SELECT COUNT(*) FROM image" );
msql.next();
println( "number of rows: " + msql.getInt(1) );
}
else
{
// connection failed !
}
}
void draw()
{
// i know this is not really a visual sketch ...
}
I used SQLibrary and I tried a ready made example which is shown at the end of the post..
What I want to do is to put this code into a separate class but I always get MySQL constructor undefined..
I suspect that the "thing" inside the msql = new MySQL( this, "localhost", database, user, pass ) causes the error but I cannot really tell..
Is there any way to replace the "thing" with something else(assuming that his is what's causing the exception..).
Thanks guys!
import de.bezier.data.sql.*;
MySQL msql;
void setup()
{
size( 100, 100 );
// this example assumes that you are running the
// mysql server locally (on "localhost").
//
// replace --username--, --password-- with your mysql-account.
//
String user = "root";
String pass = "admin";
// name of the database to use
String database = "bildwelt";
// connect to database of server "localhost"
msql = new MySQL( this, "localhost", database, user, pass );
if ( msql.connect() )
{
msql.query( "SELECT COUNT(*) FROM image" );
msql.next();
println( "number of rows: " + msql.getInt(1) );
}
else
{
// connection failed !
}
}
void draw()
{
// i know this is not really a visual sketch ...
}
1