dimanche 1 février 2015

SQLite select from LIKE statement not working?

When I view the database and run this query I get results as expected.



SELECT * FROM users WHERE options LIKE '%[-15,-3]%';


However when I use a prepared statement as seen below, the 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();

System.out.println("SELECT * FROM users WHERE options LIKE '%" + opt + "%'");

if(uuid != null){
System.out.println("not null: " + uuid);
return Database.getUser(UUID.fromString(uuid);
}


For the code above, nothing is returned in the result set. Which is very strange because I used the same query with an SQLite viewer and it returned the proper rows. How can I solve this? I don't see an issue.


Aucun commentaire:

Enregistrer un commentaire