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 › Mysql - connected but then...
Page Index Toggle Pages: 1
Mysql - connected but then... (Read 867 times)
Mysql - connected but then...
Jan 14th, 2006, 9:08am
 
Hello, I have some experience with processing, php, and mysql, but for some reason I can not return results from my query.

I imported the library: import de.bezier.mysql.*;

The following code outputs, "connected," so at least I can be sure I'm that far.  "Iterating" is never displayed.  For some reason it never goes into the while loop.

if( db.connect() ){
   text("connected", 15, 20);
   db.query( "SELECT * FROM " + table + " LIMIT 3" );
   
   while( db.next() )
   {
     text("iterating", 15, 40);
     p_name.addElement( new String(db.getString("name")) );
   }
   
   db.close();
}

I've tripled checked my database variables. Very frustrating, any help?
Re: Mysql - connected but then...
Reply #1 - Jan 14th, 2006, 8:07pm
 
if you don't get any error message, then your result is simply empty. can you run your query directly in mysql to check, pls?

feel free to contact me via mail-at-bezier.de (since i'm not around the forum too often these days ..)

F

or try this instead of the while-loop to see the number of rows:
Code:

if( db.connect() ){
text("connected", 15, 20);

db.query( "SELECT COUNT(*) FROM " + table );
db.first();
println( "number of rows: " + db.getInt(1) );

db.close();
}
Page Index Toggle Pages: 1