I'm using Hikari for my MySql DB and I'm trying to query stuff but for some reason, the getResultSet() method returns null even though it shouldn't according to the method docstring. Here's the part of the docstring: returns: the current result as a ResultSet object or null if the result is an update count or there are no more results and here's the chunk of code the error's triggered in: PreparedStatement input = connection.prepareStatement("SELECT uuid FROM Connections WHERE ip = '" + ip + "'"); ResultSet set = input.getResultSet(); while (set.next()) { out.add(set.getString("uuid")); }
#PreparedStatement.getResults() returning null
1 messages · Page 1 of 1 (latest)
im not sure if this code is actually right
but might be because of the difference between the driver's version
but here is one of my code that works:
PreparedStatement ps = // preparestatement code here
ps.codehere();
ResultSet rs = ps.executeQuery();
if (if.next()) {
//code here
}
Thing is, most times I've used the same technique and it's worked
wdym
Like, not had an issue with this: PreparedStatement input = connection.prepareStatement("SELECT ip FROM Connections WHERE uuid = '" + uuid + "'"); ResultSet set = input.executeQuery(); while (set.next()) { out.add(set.getString("ip")); }
oh wait you mean your code?
Yeah, my other functions are working fine
where uuid probably should not be "", instead set it to ?
PreparedStatement ps = connection().prepareStatement("SELECT `ip` FROM `Connections` WHERE `uuid` = ?");
ps.setString(1, uuid);
and... thats it? ;-;
well yes, executing query is always required. I remember I had many issues when I forgot to execute the query. I was so angry when I realsed the error. xD
But one thing I learned: if it says it has errors in it, it really is debugged. XD
Ugh. That's why I always add "sorry if I'm being dumb" in my messages. Because 80% of the time when I get stuck, it's because I'm being dumb