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(‘how.are.you.how.are.doing.now.new’) - LENGTH(REPLACE(‘how.are.you.how.are.doing.now.new’, ‘.’, ‘’))) DIV LENGTH(’.’)) >= 4, SUBSTRING(‘how.are.you.how.are.doing.now.new’, LENGTH(CONCAT(substring_index(‘how.are.you.how.are.doing.now.new’, ‘.’, 4), ‘.’)) + 1), null) FROM company LIMIT 1 ;
This query works fine in SQL Editor but not in the JDBC (Version 1.1.2)
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('how.are.you.how.are.doing.now.new')" +
" - LENGTH(REPLACE('how.are.you.how.are.doing.now.new', '.', ''))" +
") DIV LENGTH('.')) >= 4," +
" SUBSTRING('how.are.you.how.are.doing.now.new', LENGTH(" +
"CONCAT(substring_index('how.are.you.how.are.doing.now.new', '.', 4)" +
", '.')) + 1), null) FROM company LIMIT 1 ");
This code sample returns a non-null ResultSet containing “are.doing.now.new” with SingleStore JDBC if the company table has at least one row.