java code problem
<p>i have a bean called empbeans.java which calls dao class(userdao.java) used for inserting data into a table named emp_leaves.It inserts the values based on the ename which is brought from the session.i have a small coding problem.It is displaying a message that "Sorry! Could Not Apply For Leave!".Is there any error in userdao.java ?plz solve.</p>

<p>here is  the code.</p>

<h1>empbeans.java</h1>

<pre><code>public void apply(ActionEvent evt) {
    ename = util.getSession().getAttribute("ename").toString();
    boolean done= userdao.apply(this);
    if ( done ) {
        reason =  "";
        leavedate="";
        message = "Applied For Leave Successfully!";
    }
    else
        message = "Sorry! Could Not Apply For Leave!";
}
</code></pre>

<h1>userdao.java</h1>

<pre><code>public static boolean apply(empbeans e) {
    Connection con = null;
    PreparedStatement ps=null;
    PreparedStatement ps1=null;
    try {

        con = Database.getConnection();
        ps1=con.prepareStatement("select eid from employee where ename=?");
        ps1.setString(1,e.getEname());
        ResultSet rs=ps1.executeQuery();
        ps = con.prepareStatement(
                "insert into emp_leaves values(?,?,?,default)");
        ps.setInt(1,rs.getInt(1));
        ps.setString(1,e.getLeavedate());
        ps.setString(2,e.getReason());
        int count = ps.executeUpdate();
        return count == 1;
    } catch (Exception ex) {
        System.out.println("Error in inserting into time sheet   --&gt;" + ex.getMessage());
        return false;
    } finally {
        Database.close(con);
    }
}
</code></pre>
