读书人

提示:You have an error in your SQL

发布时间: 2012-01-19 20:57:59 作者: rapoo

提示:You have an error in your SQL syntax

Java code
/**     * 添加操作记录     */    public Statistics saveStatistics(Integer status, List<BlogStatus> batchProcess) {        Statistics stat = new Statistics();        Article article = getArticle();        User user = getLoggedOnUser();        stat.setType(2);//文章        stat.setUserId(user.getId());        Date date = new Date();        SimpleDateFormat dateformat=new SimpleDateFormat("yyyy-MM-dd");        dateformat.format(date);        stat.setStatisticsTime(date);        if(status != null) {            switch (status) {            case 0://重申                stat.setDescribe(user.getUsername() + "重申了"+article.getCommUser().getUserName()+"发表的文章" + article.getTitle());                break;            case 1://通过                stat.setDescribe(user.getUsername() +article.getCommUser().getUserName()); //article.getTitle()                break;            case 2://屏蔽                stat.setDescribe(user.getUsername() + "屏蔽了"+article.getCommUser().getUserName()+"发表的文章" + article.getTitle());                break;            case 3://删除                stat.setDescribe(user.getUsername() + "删除了"+article.getCommUser().getUserName()+"发表的文章" + article.getTitle());                break;            }        }        if(batchProcess != null) {            stat.setDescribe(user.getUsername() + "处理了"+article.getCommUser().getUserName()+"发表的文章" + article.getTitle());        }        [color=#FF0000statisticsManager.save(stat);][/color] //这里执行走不了        this.saveStatisticsDesc(stat,article);        return stat;    }


错误信息如下:

Hibernate: insert into ibokee_statistics (describe, statisticsTime, type, userId) values (?, ?, ?, ?)
WARN ["http-bio-8080"-exec-9] JDBCExceptionReporter.logExceptions(100) | SQL Error: 1064, SQLState: 42000
ERROR ["http-bio-8080"-exec-9] JDBCExceptionReporter.logExceptions(101) | You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'describe, statisticsTime, type, userId) values ('adminzhender', '2011-11-25 10:4' at line 1


[解决办法]
statisticsTime是日期型吧,可你了一字符串
[解决办法]
我你的字段,不是代
[解决办法]
反了。。。。。是你字段和你代型不
[解决办法]
SQL错误。 你的时间错了。时间要转换的。
[解决办法]
Java code
            SimpleDateFormat dateformat=new SimpleDateFormat("yyyy-MM-dd");            Date date = new Date();            date = dateformat.parse(dateformat.format(date));这样试试。。。 

读书人网 >J2EE开发

热点推荐