Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore warnings still creating warnings object for result set warnings. #118

Closed
jeber-ibm opened this issue Aug 12, 2023 · 4 comments · Fixed by #121
Closed

Ignore warnings still creating warnings object for result set warnings. #118

jeber-ibm opened this issue Aug 12, 2023 · 4 comments · Fixed by #121
Assignees

Comments

@jeber-ibm
Copy link
Member

The ignore warnings code is still creating the warnings object, even though it is ignored. The code in question is the following.

In JDServerRowCode is the following code.

         if (resultSet_ != null) { 
           resultSet_.postWarning (JDError.getSQLWarning (connection_, id_, errorClass, returnCode)); // @D1a
         } else {

Note that the warning object is always created.

The postWarning code doesn't post the warning, but the damage of the created warning object still occurred.

void postWarning(SQLWarning sqlWarning) {
/* Check to see if the warning should be ignored @q1a */
try {
if ((statement_ != null)
&& (statement_.getConnection() != null)
&& (((AS400JDBCConnection) statement_.getConnection())
.ignoreWarning(sqlWarning))) {
return;
}

} catch (SQLException e) {
  // Ignore errors from getting connection.
}
if (sqlWarning_ == null)
  sqlWarning_ = sqlWarning;
else
  sqlWarning_.setNextWarning(sqlWarning);

}

The post warning method needs to be changes so that the warning object is created only as needed.

@jeber-ibm jeber-ibm self-assigned this Aug 12, 2023
@jeber-ibm
Copy link
Member Author

The following recreate illustrates the problem.

java -Dcom.ibm.as400.access.Trace.category=ALL -jar jt400.jar "jdbc:as400:$AS400"";ignore warnings=01534,01004" $USER $PASSWORD
select date(table_cat) from sysibm.sqlcolumns fetch first 10 rows only

No warning is returned to the application, but the trace still shows the warning object being created.

@jboarman
Copy link

@jeber-ibm

Thanks for creating this issue! It'd also be nice to be able to suppress all warnings so one would not need to guess at the exact format needed, the code vs state, whether it's zero-padded, etc.

@jeber-ibm
Copy link
Member Author

Code has been pushed and is out for review. You can specify all to suppress all warnings. You can download a version of the build from https://github.com/IBM/JTOpen/suites/15082534213/artifacts/861520773

Running the following recreate did not show any warnings being created.

java -Dcom.ibm.as400.access.Trace.category=all -jar /QIBM/proddata/OS400/jt400/lib/jt400.jar 'jdbc:as400:localhost;ignore warnings=all'

select date(table_cat) from sysibm.sqlcolumns fetch first 10 rows only

@ThePrez
Copy link
Member

ThePrez commented Aug 15, 2023

Code from PR #121 merged at 431b8a7

@jeber-ibm jeber-ibm linked a pull request Aug 15, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants