How to check the identity of a value in the h2 database with the value of a variable of type String ?

 r=stat.executeQuery("SELECT * FROM USER WHERE LOGIN ='data'"); 

Instead of the text data, a variable of the String type should be passed:

r=stat.executeQuery("SELECT * FROM USER WHERE LOGIN =login");

Use PreparedStatement also failed.

    1 answer 1

    Just like this:

     String str = "Alex"; r = stat.executeQuery("SELECT * FROM USER WHERE LOGIN = '" + str + "';"); 
    • String s = "qwer"; r = stat.executeQuery ("SELECT * FROM USER WHERE LOGIN = '" + s + "';"); while (r.next ()) {System.out.print (r.getString ("Login")); } - George
    • does not display any results even though there is an entry in the database with such a login; - George
    • @ Georgy, let's get the code, then it will be easier vladislavkhripkov@mail.ru - dirkgntly