// // sql an SQL INSERT, UPDATE, or DELETE statement, or an SQL // statement that returns nothing. // // Returns either the row count for INSERT, UPDATE, or DELETE; or 0 // for SQL statements that return nothing. //———————————————————————- — public int executeUpdate( String sql) throws SQLException { if (traceOn()) { trace(”@executeUpdate(” + sql + “)”); } int count = -1; // Execute the query. If execute returns false, then an update // count exists. if (execute(sql) == false) { count = getUpdateCount(); } else { // If the statement does not create an update count, the // specification indicates that an SQLException should be raised. throw new SQLException(”Statement did not create an update count”); } return count; } As you can see, executeQuery and executeUpdate are simply helper methods for an application; they are built completely upon other methods contained within the class. The execute method accepts an SQL statement as its only parameter, and will be implemented differently, depending upon the underlying database system. For the SimpleText driver, the SQL statement will be parsed, prepared, and executed. Note that parameter markers are not allowed when executing an SQL statement directly. If the SQL statement created results containing columnar data, execute will return true; if the statement created a count of rows affected, execute will return false. If execute returns true, the application then uses getResultSet to return the current result information; otherwise, getUpdateCount will return the number of rows affected. Warnings As opposed to SQLException, which indicates a critical error, an SQLWarning can be issued to provide additional information to the application. Even though SQLWarning is derived from SQLException, warnings are not thrown. Instead, if a warning is issued, it is placed on a warning stack with the Statement object (the same holds true for the Connection and ResultSet objects). The application must then check for warnings after every operation using the getWarnings method. At first, this may seem a bit
Our unmatched NT experience allows us to provide the most reliable and affordable hosting for our customers, just check NT Web Hosting services.