K
K
KtoYa2282020-05-15 21:16:29
Java
KtoYa228, 2020-05-15 21:16:29

How to check if a record is present in a table?

There is a code:

Connection c = DriverManager.getConnection(road);
if(!c.createStatment().executeQuery("SELECT * FROM users WHERE name = 'name'").isBeforeFirst()){
//TODO... 
return;
} 
if(c.createStatment().executeQuery("SELECT * FROM users WHERE name = 'name'").getString("address") == "0.0.0.0"){
//TODO... 
return;
}


Problem: when requested, it returns that the string does not exist, even though it exists. When the first and second checks are interchanged, the first one is performed. What's the matter?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Oparin, 2020-05-15
@losse_narmo

https://ru.stackoverflow.com/questions/417405/%D0%...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question