由于order是mysql数据库的关键字,因此在查询(增删改查)的时候,该表明要用反引号括起来--->``(也就是1左边的按键)
example: select * from `order` where edi_status=1
使用Jdbc去读取远程数据库表里的时间字段,用ResultSet的实例getTimestamp("")才能获取到时分秒,getDate("")是获取不到的;
新增的时候,也是如此:如Timestamp timestamp = new Timestamp(new Date().getTime());
ps.setTimestamp(?, timestamp);
返回新增自增的ID:
PreparedStatement ps = null;
try {
connection=getConnection();
ps = connection.prepareStatement(sql, PreparedStatement.RETURN_GENERATED_KEYS);
ps.setString(1,batchNo);
ps.setString(2,"01");
ps.setString(3,"01");
ps.setInt(4,1);
Timestamp timestamp = new Timestamp(new Date().getTime());
ps.setTimestamp(5, timestamp);
// ps.setDate(5,new java.sql.Date(new Date().getTime()));
ps.setInt(6,0);
ps.executeUpdate();
ResultSet rs = ps.getGeneratedKeys();
if (rs.next()) {
long id = rs.getLong(1);
return id;
}