Null resultset on Select query with string input

I’m sending a select query using jdbc with string input, there is no resultset, it is null.
But the same query is working fine in sql editor
And it is also working with column name as input in jdbc.
Kindly support on this, I am practicing on free tier

The query:
SELECT IF(((LENGTH(‘’) - LENGTH(REPLACE(‘’, ‘.’, ‘’))) DIV LENGTH(’.’)) >= 4, SUBSTRING(‘’, LENGTH(CONCAT(substring_index(‘’, ‘.’, 4), ‘.’)) + 1), null) FROM company LIMIT 1 ;

This query works fine in SQL Editor but not in the JDBC (Version 1.1.2)

Hi @xixec88598 ! I am working to find someone who can answer this. Welcome to our forums.

1 Like

Hi @xixec88598, thank you for your report!

Could you please provide a Java code snippet that doesn’t work for you?

This may be a paste formatting issue, but the quotation symbols around string literals in your query seem weird, you should use single or double quotes (’, ") for string literals in JDBC queries. E.g.

Statement st = connection.createStatement();
st.executeQuery("SELECT IF(" +
               "((LENGTH('')" +
               " - LENGTH(REPLACE('', '.', ''))" +
               ") DIV LENGTH('.')) >= 4," +
               " SUBSTRING('',  LENGTH(" +
               "CONCAT(substring_index('', '.', 4)" +
               ", '.')) + 1), null) FROM company LIMIT 1 ");

This code sample returns a non-null ResultSet containing “” with SingleStore JDBC if the company table has at least one row.

Kind regards,