在ResultSet
updateTime:用此方法只能更新时间,日期是不确定
updateTimestamp:用此方法更新,日期和时间都是系统的当前时间
下面是用updateTimestamp方法进行更新系统时间的例子
===============================================================
package asptojsp;
import java.sql.*;
import java.util.*;
import javax.naming.*;
import java.text.*;
public class ATest {
public static void main(String[] args)throws SQLException {
try {
PreparedStatement ps= new bf1().conn.prepareStatement("select lastlogin from y_user where username='defu'",ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
ResultSet rs=ps.executeQuery();
rs.next();
rs.updateTimestamp(1,new java.sql.Timestamp(Calendar.getInstance().getTimeInMillis()));
rs.updateRow();
}
catch (NamingException ex) {
ex.printStackTrace();
}
catch (SQLException ex) {
ex.printStackTrace();
}
}
}
//=======================================
需要注意的一点是:在用到更新方法的时候,切记不要把查询字段写成 * ;否则会报错的