mercredi 12 octobre 2016

Set java variable depending on sql return value

I have the following problem:

I need to set a boolean true is an entry in a database exists.

 boolean check;
 Connection conn = DriverManager.getConnection(url,"",""); 
 Statement st = conn.createStatement();
 String sqlstat = ( (select count(*) from mytable where mdsum = '1111' and name = 'testname') > 0); 
 st.executeUpdate(sqlstat);

 --> if return is >0 then set check = true <--

How can I do this? I use DB2 if that is of importance

Thanks for your help in advance.

TheVagabond

Aucun commentaire:

Enregistrer un commentaire