[CONJ-819] Syntax error: Encountered \"<\" Created: 2020-08-14  Updated: 2020-11-17  Resolved: 2020-11-17

Status: Closed
Project: MariaDB Connector/J
Component/s: Other
Affects Version/s: 2.6.2
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Daniel Mack Assignee: Diego Dupin
Resolution: Incomplete Votes: 0
Labels: None
Environment:

OS. Suse Linux Enterprise Server 12.2



 Description   

Hello,

we are trying to execute this query:
select csc from cscs WHERE context = :source_host AND ((INET_NTOA((-1 << (33 - INSTR(BIN(INET_ATON(subnetmask)), '0')))&INET_ATON(:src_ip))=subnetmask) OR (INET_NTOA((-1 << (33 - INSTR(BIN(INET_ATON(subnetmask)), '0')))&INET_ATON(:dst_ip))=subnetmask))

then we are getting this error message:
Java::JavaSql::SQLSyntaxErrorException: Syntax error: Encountered \"<\" at line 1, column 73.

We tried different mysql as well as mariadb connectors, but with the same result.
It seems to be, that the connector thoughts that the < is not included in the sql syntax.

Greetings

Daniel



 Comments   
Comment by Diego Dupin [ 2020-08-17 ]

testing with some snippet like :

    try (Connection con = DriverManager.getConnection("jdbc:mariadb://localhost:3306/testj?user=root&log")) {
      try (PreparedStatement preparedStatement = con.prepareStatement(
      "SELECT INET_NTOA((-1 << (33 - INSTR(BIN(INET_ATON(?)), '0')))&INET_ATON('192.168.1.15'))")) {
        preparedStatement.setString(1, "192.168.1.0");
        ResultSet rs = preparedStatement.executeQuery();
        rs.next();
        System.out.println(rs.getString(1));
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    }

doesn't seem to cause any issues.

Parameters like ":source_host" are not handle by driver. Driver use question mark as parameter.
So some parser must change query somehow.

Could you add option `dumpQueriesOnException=true` on connection string / log network with tools like Wireshark to see exactly what command is received by driver ?

Comment by Diego Dupin [ 2020-11-17 ]

closing since no answer since more than 3 months

Generated at Thu Feb 08 03:18:32 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.