When I browse the database and run this query, I get the results as expected.
SELECT * FROM users WHERE options LIKE '%[-15,-3]%';
However, when I use a prepared statement as shown below, uuid is null.
String opt = "[-15,-3]"; //example PreparedStatement ps = SQLite.connection.prepareStatement( "SELECT * FROM users WHERE options LIKE '%" + opt + "%'" ); ResultSet rs = ps.executeQuery(); String uuid = null; while (rs.next()){ uuid = rs.getString("member"); } rs.close(); ps.close(); if(uuid != null){ System.out.println("not null: " + uuid); return Database.getUser(UUID.fromString(uuid); }
For the above code, nothing is returned in the result set. This is very strange because I used the same query with SQLite viewer and returned the correct rows. How can i solve this? I do not see a problem.
UPDATE
When I directly use "SELECT * FROM factions WHERE claims LIKE '%[-15,-3]%'" in the prepared expression instead of a variable, it works fine. Why can't I use a string variable? I checked the variable and it prints fine to the console.
source share