Please help me, give me an example how to error handling (or print error message) if I have an wrong query. I have tried this code with wrong table name (TB_DAT => TB_DATA) but the SQLException doesn't return anything.
Connection_T conn = ConnectionPool_getConnection(pool);
TRY { ResultSet_T r = Connection_executeQuery( conn, "select id from TB_DAT" );
while ( ResultSet_next( r ) ) __PRINT( ResultSet_getString( r, 1 ) ); } CATCH( SQLException ) { printf( "SQLException - %s\n", Exception_frame.message ); } FINALLY { Connection_close( conn ); } END_TRY;
Thanks Hans
On 06/19/2012 10:37 AM, Hans Richardo wrote:
Please help me, give me an example how to error handling (or print error message) if I have an wrong query. I have tried this code with wrong table name (TB_DAT => TB_DATA) but the SQLException doesn't return anything.
Iirc, failed queries don't show up in Exception_frame.message. I always log the separately in the CATCH block.
On Jun 19, 2012, at 11:16 AM, Paul J Stevens wrote:
On 06/19/2012 10:37 AM, Hans Richardo wrote:
Please help me, give me an example how to error handling (or print error message) if I have an wrong query. I have tried this code with wrong table name (TB_DAT => TB_DATA) but the SQLException doesn't return anything.
Iirc, failed queries don't show up in Exception_frame.message. I always log the separately in the CATCH block.
Errors should be reported correct and fully. This was an omission for MySQL which is fixed now. I'll release 2.10.4 right away.
AFAIK error reporting for query and prepared statements works fine for the other database systems, though only tested for SQLite since I don't have a running Oracle nor Postgres server at the moment. Maybe someone who is using libzdb with Oracle or Postgres could test?
For example that "select * from foo" reports a proper error if the foo table does not exist.