Troubleshooting
Problem
The IBM® Developer Kit for Java™ JDBC driver throws an SQLException if the statement object's executeQuery() / executeUpdate() methods are used incorrectly.
Resolving The Problem
The IBM® Developer Kit for Java™ (native) JDBC driver throws an SQLException if the statement object's executeQuery() / executeUpdate() methods are used incorrectly. If the statement method executeQuery() is used to run an SQL statement that does not produce a ResultSet, the driver is required to throw an SQLException. In addition, if the statement method executeUpdate() is used to run an SQL statement that does produce a ResultSet, the driver is also required to throw an SQLException. These conditions are defined by the JDBC specification. If an application causes either of these conditions to occur, an error similar to the following occurs:
If it is suspected that the function sequence error was caused by one of these conditions, a native JDBC trace can be gathered to confirm. There are trace points that indicate that executeQuery did not produce a ResultSet or that executeUpdate did produce a ResultSet:
OR
Overriding Default Behavior
If an application encounters this error and cannot easily be changed, the default behavior described previously can be overridden by a connection property. To prevent the driver from throwing an exception, the application must specify a behavior override value of 1. This value can be specified with the connection URL, the properties passes to the getConnection method, or by a change to the data source. The following example shows how to override the behavior with the connection URL:
Eventually, an application must be changed to be compliant with the JDBC specification. If the results of an SQL statement are not known at design time, the execute() method can be used to run the SQL statement. This method should return true if a ResultSet is available, and false otherwise.
com.ibm.db2.jdbc.app.DB2JDBCException: Function sequence error. If it is suspected that the function sequence error was caused by one of these conditions, a native JDBC trace can be gathered to confirm. There are trace points that indicate that executeQuery did not produce a ResultSet or that executeUpdate did produce a ResultSet:
Jdbc: 1037638419.610040 0000002e: DB2Statement@1266159951 DB2JDBCException(HY010) -- executeQuery.No result set returned from Statement.executeQueryOR
Jdbc: 1037637960.800248 00000027: DB2Statement@-141293470 DB2JDBCException(HY010) -- executeUpdate.result set returnedOverriding Default Behavior
If an application encounters this error and cannot easily be changed, the default behavior described previously can be overridden by a connection property. To prevent the driver from throwing an exception, the application must specify a behavior override value of 1. This value can be specified with the connection URL, the properties passes to the getConnection method, or by a change to the data source. The following example shows how to override the behavior with the connection URL:
Connection cn = DriverManager.getConnection("jdbc:db2://*LOCAL;behavior override=1;", null, null);Eventually, an application must be changed to be compliant with the JDBC specification. If the results of an SQL statement are not known at design time, the execute() method can be used to run the SQL statement. This method should return true if a ResultSet is available, and false otherwise.
[{"Product":{"code":"SWG60","label":"IBM i"},"Business Unit":{"code":"BU070","label":"IBM Infrastructure"},"Component":"Data Access","Platform":[{"code":"PF012","label":"IBM i"}],"Version":"Version Independent","Edition":"","Line of Business":{"code":"LOB68","label":"Power HW"}}]
Historical Number
28720620
Was this topic helpful?
Document Information
Modified date:
03 July 2025
UID
nas8N1016748