This is how I will do it:String myVar= "8888888";rset = stmt.executeQuery(" SELECTlog_field1 " + " FROM " + "transaction0 where "+"'log_field5='" +myVar+ ")";