Closed nickbloomzz closed 11 years ago
You are mixing plain JDBC code with my library which is not what it was made for. Use either or, and yes you can use pure JDBC in Processing.
See included examples for how to iterate over a result set.
Hello, I'm not sure what you mean but the postgresql example certainly does not have anything like result set, and I cannot see 'Result set' anywhere in your code, neither PreparedStatement or CallableStatement.
And as for using JDBC in Processing, I wish I can, because of all the documented methods, however I can't find an example of how to import JDBC into Processing anywhere on the internet.
There is no ResultSet because that is not part of my library but what the examples show you is how to iterate results. Please take the time to study those:
Hello,
I wish to populate an array with the query result, and the normal way is with resultSet rs = pgsql.query(query); however I get the message 'cannot convert from void to resultset' even when importing additional libraries. import de.bezier.data.sql.*; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement;
String user = "postgres"; String pass = "a"; String database = "wordnet30"; ArrayList <String[]> result = new ArrayList<String[]>();
PostgreSQL pgsql; pgsql = new PostgreSQL( this, "localhost:5432", "wordnet30", "postgres", "a" ); if ( pgsql.connect() ) { //Statement st = conn.createStatement(); ResultSet rs = pgsql.query("SELECT * FROM ra"); int columnCount = rs.getMetaData().getColumnCount(); while(pgsql.next()) { String[] row = new String[columnCount]; for (int i = 0; i < columnCount; i++) { row[i] = rs.getString(i+1); } result.add(row);
Is there a way around this? Is it feasible to use the JDBC directly in Processing, and avoiding 'public static void main' ? Best regards, Nicholas Bloom