pilipili在线视频⽹站开发⽇志(⼀)
 模仿bilibili做了⼀个pilipili在线视频⽹站
我主要负责接⼝的实现
leader给了我两个接⼝:UserDao VideoDao
使⽤的框架为SSM
今天遇到的错误问题:
1 org.ptions.PersistenceException:
2 ### Error updating database.  Cause: ptions.jdbc4.MySQLSyntaxErrorException: 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 'de
3 ### The error may involve defaultParameterMap
4 ### The error occurred while setting parameters
5 ### SQL: insert into p_video(name, desc, releaseDate, clickTimes, pictureUrls, videoUrl, state, user_id, category_id) values(?, ?, ?, ?, ?, ?, ?, ?, ?)syntaxerror是什么错误
6 ### Cause: ptions.jdbc4.MySQLSyntaxErrorException: 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 'desc, releaseDate, clickTim 明明没有语法错误,可是仍然报错。。。
后来发现,在建表时,居然使⽤了desc关键字作为列名
解决的⽅法为:使⽤反单引号把desc引起来
sql语句如下:
1 insert into p_video(`name`, `desc`, releaseDate, clickTimes, pictureUrls, videoUrl, state, user_id, category_id) values(#{video.name}, #{video.desc}, #{leaseDate}, #
{video.clickTimes}, #{video.pictureUrls}, #{video.videoUrl}, #{video.state}, #{user_id}, #{category_id})
2019-12-26 15:30
报错如下:
1 org.ptions.PersistenceException:
2 ### Error querying database.  Cause: java.lang.UnsupportedOperationException
3 ### The error may exist in file [D:\Git_Repository\pilipili\target\classes\l]
4 ### The error may involve com.pilipili.dao.VideoDao.selectVideosByClickTimes
5 ### The error occurred while handling results
6 ### SQL: select id, `name`, `desc`, releaseDate, clickTimes, pictureUrls, videoUrl, state, user_id, category_id from p_video where user_id=? order by clickTimes desc limit 0, ?
7 ### Cause: java.lang.UnsupportedOperationException
原因是在 l 中 resultType="list"
即使要返回list类型,这⾥也应该写成video类型,如果查询到多条数据,会⾃动放⼊list中