table1中有字段outdate(date),
其中有一条记录的值是'2008-4-1 14:12:00'
现在出现两个问题:
1,在修改页面中,先把原有值读出来,显示结果'2008-4-1 14:12:00.0',莫名其妙的多了个.0,读出来的代码如下
<input value="<%=outbean.getOutdate()%>" name="Outdate" type="text" id="Outdate" onFocus="setday(this)">2,在执行修改时,提示错误“日期格式图片在转换整个输入字符串之前结束”,代码如下(错误在两个date字段上): public int updateOutNotice(OutNoticeBean bean)
{
int result = 0;
Connection conn = DbConn.getConn();
PreparedStatement pst = null;
String sql = "update outnotice set shipperid=?,receiverid=?,driverid=?,"+
"currencyid=?,carnum=?,requireoutdate=to_date(?,'yyyy-mm-dd hh24:mi:ss'), "+
"outdate=to_date(?,'yyyy-mm-dd hh24:mi:ss'),state=?,operationid=?, "+
"re=? "+
"where id=" + bean.getId();
try {
pst = conn.prepareStatement(sql);
pst.setInt(1, bean.getShipperid());
pst.setInt(2, bean.getReceiverid());
pst.setInt(3, bean.getDriverid());
pst.setInt(4, bean.getCurrencyid());
pst.setString(5, bean.getCarnum());
pst.setString(6, bean.getRequireoutdate());
pst.setString(7, bean.getOutdate());
pst.setString(8, bean.getState());
pst.setInt(9, bean.getOperationid());
pst.setString(10, bean.getRe());
System.out.println(sql);
result = pst.executeUpdate();
} catch (SQLException ex) {
ex.printStackTrace();
} finally { try { pst.close();
pst = null;
conn.close();
conn = null;
} catch (SQLException e) { e.printStackTrace();
} }
return result;
}
其中有一条记录的值是'2008-4-1 14:12:00'
现在出现两个问题:
1,在修改页面中,先把原有值读出来,显示结果'2008-4-1 14:12:00.0',莫名其妙的多了个.0,读出来的代码如下
<input value="<%=outbean.getOutdate()%>" name="Outdate" type="text" id="Outdate" onFocus="setday(this)">2,在执行修改时,提示错误“日期格式图片在转换整个输入字符串之前结束”,代码如下(错误在两个date字段上): public int updateOutNotice(OutNoticeBean bean)
{
int result = 0;
Connection conn = DbConn.getConn();
PreparedStatement pst = null;
String sql = "update outnotice set shipperid=?,receiverid=?,driverid=?,"+
"currencyid=?,carnum=?,requireoutdate=to_date(?,'yyyy-mm-dd hh24:mi:ss'), "+
"outdate=to_date(?,'yyyy-mm-dd hh24:mi:ss'),state=?,operationid=?, "+
"re=? "+
"where id=" + bean.getId();
try {
pst = conn.prepareStatement(sql);
pst.setInt(1, bean.getShipperid());
pst.setInt(2, bean.getReceiverid());
pst.setInt(3, bean.getDriverid());
pst.setInt(4, bean.getCurrencyid());
pst.setString(5, bean.getCarnum());
pst.setString(6, bean.getRequireoutdate());
pst.setString(7, bean.getOutdate());
pst.setString(8, bean.getState());
pst.setInt(9, bean.getOperationid());
pst.setString(10, bean.getRe());
System.out.println(sql);
result = pst.executeUpdate();
} catch (SQLException ex) {
ex.printStackTrace();
} finally { try { pst.close();
pst = null;
conn.close();
conn = null;
} catch (SQLException e) { e.printStackTrace();
} }
return result;
}
解决方案 »
- 新手提问:Java中为什么bety、char、short不能互相隐转换?
- java使用Statement执行多条sql.在线等!!!
- Java sql调用后存储格式问题请高手帮忙看看
- 课程设计,都快把我搞麻了...谁能帮忙看一下...MS很简单,但就是搞不明白...
- applet 中使用 java communication api 20出现ClassNotFoundException: com.sun.comm.Win32Driver异常
- JAVA题:如何实现给当前时间的分钟加15呢?
- 请帮忙解决一个正则表达式!
- GregorianCalendar 的问题,想做个时间检查器,可是有问题,请大家一起帮忙
- 如何更换窗口左上方的java图标
- 关于java应用程序
- 如何将一个Application 五子棋 转成 b/s 模式的 servlet + applet 程序?????????
- 大姐求助:a除以b 再加0.5 然后四舍五入怎么写这个代码 ?
requireoutdate=to_date(?,'yyyy-mm-dd hh24:mi:ss')在这里加入的时候是不是类型有问题
你把运行后的sql语句贴出来看看