Could anybody tell me if I can use INSERT function in processing with MySQL?
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 ... }
type of column "one" is INT. How should i write correctly to insert some numbers, and variables????
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)
int w = 800; int h = 600; int framerate = 60; int threshold = 80;
boolean find=true;
PFont font;
void setup() {
size( w*2+30, h*2+30 );
opencv = new OpenCV( this ); //opencv.capture(w,h);
//My cam should be listed - otherwise GSVideo lib probably not working String[] cameras = GSCapture.list();
if (cameras.length == 0) { println("There are no cameras available for capture."); exit(); } else { println("Available cameras:"); for (int i = 0; i < cameras.length; i++) println(cameras[i]); cam = new GSCapture(this, w, h, cameras[0]); cam.frameRate(framerate); } //Get some space for our own Image opencv.allocate(w,h);
font = loadFont( "AndaleMono.vlw" ); textFont( font );
println( "Drag mouse inside sketch window to change threshold" ); println( "Press space bar to record background image" );
}
void draw() { if (cam.available() == true) {
background(0); //don't read - load from other cam //opencv.read(); cam.read(); opencv.copy(cam);
Until I use "Blob[] blobs = opencv.blobs( 100, w*h/3, 20, true );" all is going ok. opencv.image(); is colour RGB, and remember function works correctly.
BUT, when I including this line "Blob[] blobs = opencv.blobs( 100, w*h/3, 20, true );", code is going crazy!
0) actually, it's because of opencv.blobs(); function exactly... I can't find solution on forums..
1) opencv.image() gimme grayscaled image
2) remember() function doesnot work anymore...
when I use opencv.remember(); or opencv.remember(OpenCV.SOURCE); , memory image is black! only one pixel in first line of image is pink (hmm..)
if I use opencv.remember(OpenCV.BUFFER); - I get some strange picture, white pixels on the edges of contrast shapes...
So, I can't use absDiff(); function correctly too because of this bug...
Can you help me?
p.s. I use: windows XP SP3, processing 1.2.1, opencv 1.0, gsvideo 0.4.5-win. As I know, opencv >1.0 doesn't support processing, am I right?
p.p.s. Usage of opencv.capture instead of GSCapture gimme workable functions, RGB image, but verrry slow framerate...
Can you test this code on your computer, maybe it's depends on windows version...