Hi, It must be more related to using SIGNAL inside a stored procedure, server doesn't send warning to driver in this case. Warning does inside java connector when server send warning information. Example : try (Statement stmt = sharedConnection.createStatement()) { stmt.execute("create or replace procedure pwarning()\n" + "begin\n" + " DROP TABLE IF EXISTS test.no_such_table;\n" + "end"); stmt.execute("call pwarning()"); SQLWarning sqlWarning = stmt.getWarnings(); Assert.assertNotNull(sqlWarning); Assert.assertTrue(sqlWarning.getMessage().contains("Unknown table 'test.no_such_table'")); } regards, Diego. On Wed, Apr 5, 2017 at 8:24 AM, jerome brauge <j.brauge@qualiac.com> wrote:
Hello Daniel, In fact, getWarnings works fine when there is no error. The following procedure issues one warning and one error, and in this case getWarnings() (called inside SQLException catch) returns null even with reenableWarnings().
create or replace procedure pwarning1() begin SIGNAL SQLSTATE '01000'; RESIGNAL SET MESSAGE_TEXT = 'error message'; end /
Regards, Jérôme.
-----Message d'origine----- De : Maria-developers [mailto:maria-developers- bounces+j.brauge=qualiac.com@lists.launchpad.net] De la part de Daniel Black Envoyé : mercredi 5 avril 2017 03:09 À : maria-developers@lists.launchpad.net; Diego Dupin Objet : Re: [Maria-developers] JDBC getWarnings and stored procedure
On 03/04/17 20:21, jerome brauge wrote:
Hello,
When we call a stored procedure in JDBC which emit warnings, getWarnings() always returns null.
I don't really think that the problem is in MariaDB Connector J because warning flag in the EOF packet is not set to true.
hasWarnings is set:
https://github.com/MariaDB/mariadb-connector- j/blob/master/src/main/java/org/mariadb/jdbc/internal/protocol/AbstractC onnectProtocol.java#L745
Its used here:
https://github.com/MariaDB/mariadb-connector- j/blob/master/src/main/java/org/mariadb/jdbc/MariaDbConnection.java#L8 27
I suspect the bug is warningsCleared has a implicit default of false in the above class.
As a workaround check, call reenableWarnings() before getWarnings().
Mysql client behaves in the same way, by default it shows warnings count issued by DML command but not for stored procedure.
Is it a normal behavior ?
Best regards,
Jérôme.
_______________________________________________ Mailing list: https://launchpad.net/~maria-developers Post to : maria-developers@lists.launchpad.net Unsubscribe : https://launchpad.net/~maria-developers More help : https://help.launchpad.net/ListHelp
_______________________________________________ Mailing list: https://launchpad.net/~maria-developers Post to : maria-developers@lists.launchpad.net Unsubscribe : https://launchpad.net/~maria-developers More help : https://help.launchpad.net/ListHelp