MySQL to java | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

MySQL to java

How do i write SELECT debt FROM client where dni =? On java? Is it okay public boolean isDebtbyDNI(String dni) { PreparedStatement stat = null; ResultSet rs = null; Connection con = connection.getConexion(); boolean debt = false; try { stat = con.prepareStatement("SELECT debt FROM client where dni =?"); stat.setString(1, dni); rs = stat.executeQuery(); while (rs.next()) { debt = rs.getBoolean("debt"); } return debt; } //etc etc catchs under there

28th Jun 2020, 2:47 AM
Pame
Pame - avatar
2 Answers
+ 1
You have to escape your line breaks and execute the statement, then yes as far as I can see (quick look).
28th Jun 2020, 3:57 AM
Sandra Meyer
Sandra Meyer - avatar
0
will that give me the same result as "SELECT debt FROM client where dni = something"
28th Jun 2020, 2:50 AM
Pame
Pame - avatar