首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2EE开发 >

提示:You have an error in your SQL syntax,该怎么处理

2012-01-19 
提示:You have an error in your SQL syntaxJava code/*** 添加操作记录*/public Statistics saveStatisti

提示: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));这样试试。。。 

热点排行