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 How many records in the result
Page Index Toggle Pages: 1
MySQL How many records in the result? (Read 599 times)
MySQL How many records in the result?
May 21st, 2008, 11:43am
 
I have written a mysql database application using the example in http://www.bezier.de/mysql/

I am thinking of loading the results to object array. How do I find out how many rows in the result? I need the row count to declare the array.


Or is there a way to dynamically increase array size? So I can keep increasing the array size until I reach the last element using MySQL.next()

Are there List, Vector type things in processing?
Re: MySQL How many records in the result?
Reply #1 - May 26th, 2008, 11:54am
 
I can answer the last question: YES.
You have access to all the Java collections, like Vector or ArrayList. Then use toArray to convert to plain array if you need to.
Re: MySQL How many records in the result?
Reply #2 - May 26th, 2008, 12:35pm
 
Code:

// use SQL, like:
msql.query( "SELECT COUNT(*) FROM " + table );
msql.next();
println( "number of rows: " + msql.getInt(1) );


F
Page Index Toggle Pages: 1