[求助]??access2000为什么不行??
String time = (new java.util.Date().toLocaleString());
stmt.executeUpdate("insert into guest (username,sex,email,qq,url,content,images,ip,time) values ('"+username+"','"+sex+"','"+email+"','"+qq+"','"+url+"','"+content+"','"+tx+"','"+ip+"','"+time+"')");
我用Mysql数据库可以添加记录,但是access2000不行(查出是time的问题),如何转换time为String??
错误:
sqle=java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] INSERT INTO 语句的语法错误。
问题点数:0、回复次数:1Top
1 楼liusoft(红薯)回复于 2004-08-02 17:56:34 得分 0
用PreparedStatement吧,用动态参数的方式来执行,例如
PreparedStatement ps = conn.prepareStatement("INSERT INTO guest(?,?");
ps.setString(1,'hello');
ps.setTimestamp(2, new Timestamp(System.currentTimeInMills());
ps.executeUpdate();
http://www.javayou.comTop




