MySQL Syntaxis in processing
in
Programming Questions
•
3 years ago
Could anybody tell me if I can use INSERT function in processing with MySQL?
I use simpliest code:
Because I have this:
SQL.query(): java.sql.SQLException.
java.sql.SQLException: Can not issue data manipulation statements with executeQuery().
at com.mysql.jdbc.Statement.checkForDml(Statement.java:305)
at com.mysql.jdbc.Statement.executeQuery(Statement.java:885)
at de.bezier.data.sql.SQL.query(Unknown Source)
at MySQL_example1.setup(MySQL_example1.java:61)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.core.PApplet.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)
I use simpliest code:
- 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 = "test";
String pass = "666666";
String database = "test";
msql = new MySQL( this, "localhost", database, user, pass );
if ( msql.connect() )
{
msql.query( "SELECT COUNT(*) FROM simple" ); //Here is OK.
msql.next();
println( "number of rows: " + msql.getInt(1) );
// msql.query( "INSERT INTO `test`.`simple` (`one`) VALUES ('2');" ); //Error..
msql.query( "INSERT INTO simple (one) VALUES (2);" ); //Error too..
}
else
{
// connection failed !
}
}
void draw()
{
// i know this is not really a visual sketch ...
}
Because I have this:
SQL.query(): java.sql.SQLException.
java.sql.SQLException: Can not issue data manipulation statements with executeQuery().
at com.mysql.jdbc.Statement.checkForDml(Statement.java:305)
at com.mysql.jdbc.Statement.executeQuery(Statement.java:885)
at de.bezier.data.sql.SQL.query(Unknown Source)
at MySQL_example1.setup(MySQL_example1.java:61)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.core.PApplet.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)
1