Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Not throwing SQLException on invalid query

843859Sep 27 2005 — edited Sep 29 2005
Hi

Im pretty new to JDBC and all that. At uni we are doing a project and im having a bit of difficulty with exceptions.

We mainly use NBCachedRowSet from org.netbeans.lib.sql.*

i used the following code to return a NBCachedRowSet.
try
        {
            NBCachedRowSet rowset = new NBCachedRowSet();
            ConnectionSource connSrc = getConnector(database);
            
            rowset.setConnectionSource(connSrc);
            rowset.setCommand(query);
            
            return rowset;
        }
        catch (SQLException e) { System.out.println(e.getSQLState()); } 
"query" is the given SQL query string.

This works fine and i can use the returned rowset without any problems.

My problem is actually that even when the query is invalid it doesnt complain. When i use the rowset in a tablemodel then it just keeps the table empty but still doesnt complain. The thing is... I want it to complain that the query is invalid !!!

I tried using rowset.execute(query) instead of rowset.setCommand(query) but still no SQLException. I tried using "asdfasdf" as the query which is obviously rubbish but still no Exception is thrown !!!

What am i missing out here??
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 27 2005
Added on Sep 27 2005
7 comments
229 views