mysql项目报错,希望大神帮忙看看

qq_39277883 2019-06-18 06:40:26
各路大神帮忙看看,谢谢
com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '12 * from movies where movieID not in(select top 0 movieID from movies order by' at line 1
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2985)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1631)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1723)
at com.mysql.jdbc.Connection.execSQL(Connection.java:3283)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1332)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1467)
at com.wyy.dao.BaseDao.exQuerySelect(BaseDao.java:106)
at com.wyy.Impl.MovieDaoImpl.search(MovieDaoImpl.java:256)
at org.apache.jsp.movielist_jsp._jspService(movielist_jsp.java:193)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:438)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:94)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:492)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:502)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1152)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:684)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1539)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1495)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)



以下是代码

package com.wyy.Impl;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import com.wyy.dao.BaseDao;
import com.wyy.dao.MovieDao;
import com.wyy.entity.Movie;
public class MovieDaoImpl extends BaseDao implements MovieDao {
//添加电影
public int addMoviesInfo(Movie movie) {

int count=0;
try {

String sql="insert into movies(movieName,director,typeID,stardom,region,showtime,description,image)" +
"values(?,?,?,?,?,?,?,?)";

String[] paras={movie.getMovieName(),movie.getDirector(),String.valueOf(movie.getTypeID()),movie.getStardom(),movie.getRegion(),
movie.getShowtime(),movie.getDescription(),movie.getImage()};

count=super.exQureyUpDelAdd(sql, paras);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{

super.closeResousAll();
}

return count;
}

public int deleteMoviesInfo(int moviesId) {

int count=0;
try {

String sql="delete from movies where movieID=?";

String[] paras={String.valueOf(moviesId)};

count=super.exQureyUpDelAdd(sql, paras);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{

super.closeResousAll();
}

return count;
}

public int deleteMoviesInfo(String moviesId) {

int row=0;
try {

String sql="delete from movies where movieid in("+moviesId+")";

row=super.exQureyUpDelAdd(sql,null);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

return row;
}

public int updateMoviesInfo(Movie movie) {

int count =0;
try {

String sql="update movies set movieName=?," +
"director=?,typeID=?,stardom=?,region=?,showtime=?," +
"description=?,image=?, price=?,count=?,sellCount=? where movieID=?";

String[] paras={movie.getMovieName()
,movie.getDirector(),String.valueOf(movie.getTypeID()),
movie.getStardom(),movie.getRegion(),movie.getShowtime(),
movie.getDescription(),movie.getImage(),
String.valueOf(movie.getPrice()),String.valueOf(movie.getCount())
,String.valueOf(movie.getSellCount()),String.valueOf(movie.getMovieID())};

count=super.exQureyUpDelAdd(sql, paras);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{

super.closeResousAll();
}

return count;
}

public List<Movie> selectMoviesInfo() {
// TODO Auto-generated method stub
return null;
}

public int selectMoviesInfoChongFu(Movie movie){

int count=0;
try {

String sql="select count(*) from movies where movieName=? and typeId=?";

String[] paras={movie.getMovieName(),String.valueOf(movie.getTypeID())};

re=super.exQuerySelect(sql, paras);

if(re.next()){

count=re.getInt(1);
}
}catch(Exception a){
a.printStackTrace();
}finally{

super.closeResousAll();
}

return count;
}

public List<Movie> selectMoviesInfo(int typeId) {

List<Movie> listmovies=new ArrayList<Movie>();
try {

String sql="select * from movies where typeId=?";

String[] paras={String.valueOf(typeId)};

re=super.exQuerySelect(sql, paras);

while(re.next()){

Movie movies=new Movie();

movies.setMovieID(re.getInt(1));
movies.setMovieName(re.getString(2));
movies.setDirector(re.getString(3));
movies.setTypeID(re.getInt(4));
movies.setStardom(re.getString(5));
movies.setRegion(re.getString(6));
movies.setShowtime(re.getString(7));
movies.setDescription(re.getString(8));
movies.setImage(re.getString(9));
movies.setPrice(re.getDouble(10));
movies.setCount(re.getInt(11));
movies.setSellCount(re.getInt(12));

listmovies.add(movies);
}
} catch (Exception e) {

e.printStackTrace();
}finally{

super.closeResousAll();
}

return listmovies;
}

public int countMovies(int typeID) {

int count=0;
try {
if(typeID!=-1){

String sql="select count(*) from movies where typeid=?";

String[] paras={String.valueOf(typeID)};

re=super.exQuerySelect(sql, paras);

}else{

String sql="select count(*) from movies ";

String[] paras=null;

re=super.exQuerySelect(sql, paras);

}
if(re.next()){

count=re.getInt(1);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{

super.closeResousAll();
}

return count;
}

public List<Movie> search(int pageNo, int typeID) {

List<Movie> lists=new ArrayList<Movie>();
try {

int pageSize=12;

int rows=0;

if(pageNo>1){

rows=(pageNo-1)*pageSize;
}

if(typeID!=-1){
String sql="select top "+pageSize+" * from movies where " +
"typeID="+typeID+" and movieID not in(select top "+rows+" movieID " +
"from movies where typeID="+ typeID + " order by movieID)" +
" order by movieID";


String[] paras=null;

re=super.exQuerySelect(sql, paras);
}else{
String sql="select top "+pageSize+" * from movies where movieID not in(select top "+rows+" movieID " +
"from movies order by movieID) order by movieID";

String[] paras=null;

re=super.exQuerySelect(sql, paras);
}

while(re.next()){

Movie movies=new Movie();

movies.setMovieID(re.getInt(1));
movies.setMovieName(re.getString(2));
movies.setDir
...全文
132 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
对梦想的牵挂 2019-06-21
  • 打赏
  • 举报
回复
Mysql的版本问题,你的版本不支持你写的这种SQL,修改SQL语句
咸哼酒家 2019-06-19
  • 打赏
  • 举报
回复
* from movies where movieID not in 这句话附近

SQL语法错误,mysql这种top语法, mysql用的的limit

re=super.exQuerySelect(sql, paras);
}else{
String sql="select top "+pageSize+" * from movies where movieID not in(select top "+rows+" movieID " +
"from movies order by movieID) order by movieID";

String[] paras=null;

re=super.exQuerySelect(sql, paras);
}

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧