Getting date from the DB and add days to it in Java
<pre><code>res = stat.executeQuery("select st_date from tmp1 where Name = '"
    + tname.getText() + "'");
while (res.next()) {
    System.out.println(res.getDate(1));
    int i = 0;
    while (i &lt; 14) {
        statement.executeUpdate("Insert into datetab values(DATE_ADD('"
            + res.getDate("st_date") + "',INTERVAL 1 DAY),'" + tempname + "')");
        i = i + 1;
    }
}
</code></pre>

<p>All the updates in <code>datetab</code> table occurs, but there is a problem. I will explain the problem with an example.</p>

<p>If the date from <code>tmp1</code> table is <code>28-12-2000</code> then after executing the insert query with <code>date_add()</code>, what happens is that 13 new inserts are happening, but all those inserts are <code>29-12-2000</code>.</p>
