Help with a JDBC problem
<p>This is a function that returns the minimum doctor ID from a doctor table after accepting a string <code>s</code> that is a consultation field in the patient table. For example, if I wrote "cardiology" in the field, then it will return the minimum doctor ID relating to that field.</p>

<p>Also, if a doctor is free or not will be decided by its current status.</p>

<p>By default, the doctor is free, and will be changed to yes after he has been allotted.</p>

<p>There are problems in the SQL statements.</p>

<pre><code>public int getDocID(String s)
{
    int did = 0;
    try {
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        Connection con =
            DriverManager.getConnection("jdbc:odbc:patientDSN");
        Statement stat = con.createStatement();
        ResultSet rs =
            stat.
            executeQuery
            ("select min(Doc_ID) from Doctor where (Doc_CurrentStatus='No' and Doc_Speciality like '%"
             + s + "'%'");
        if (rs.next()) {
            did = rs.getInt(1);
        }
        System.out.println(did);
        PreparedStatement ps1 =
            con.
            prepareStatement
            ("UPDATE Doctor SET Doc_CurrentStatus='Yes' where Doc_ID = "
             + did + "");
        ps1.executeUpdate();
    }

    catch(Exception e) {
        e.printStackTrace();
    }
    return did;
}
</code></pre>
