###前提・実現したいこと
エラーが出てしまいます。
###発生している問題・エラーメッセージ
HTTPステータス 500 - An exception occurred processing JSP page /book_kanri.jsp at line 50 type 例外レポート メッセージ An exception occurred processing JSP page /book_kanri.jsp at line 50 説明 The server encountered an internal error that prevented it from fulfilling this request. 例外 org.apache.jasper.JasperException: An exception occurred processing JSP page /book_kanri.jsp at line 50 47: 48: ps = con.prepareStatement(sql); 49: 50: rs = ps.executeQuery(); 51: %> 52: <p> 53: ジャンル <select name="genreno"> Stacktrace: org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:567) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:454) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340) javax.servlet.http.HttpServlet.service(HttpServlet.java:725) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 原因 javax.servlet.ServletException: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Column 'delete_flg' in where clause is ambiguous org.apache.jsp.book_005fkanri_jsp._jspService(book_005fkanri_jsp.java:275) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) javax.servlet.http.HttpServlet.service(HttpServlet.java:725) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:431) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340) javax.servlet.http.HttpServlet.service(HttpServlet.java:725) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 原因 com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Column 'delete_flg' in where clause is ambiguous sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) java.lang.reflect.Constructor.newInstance(Constructor.java:422) com.mysql.jdbc.Util.handleNewInstance(Util.java:404) com.mysql.jdbc.Util.getInstance(Util.java:387) com.mysql.jdbc.SQLError.createSQLException(SQLError.java:934) com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3966) com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3902) com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2526) com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2673) com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2549) com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1861) com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1962) org.apache.tomcat.dbcp.dbcp2.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:82) org.apache.tomcat.dbcp.dbcp2.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:82) org.apache.jsp.book_005fkanri_jsp._jspService(book_005fkanri_jsp.java:166) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) javax.servlet.http.HttpServlet.service(HttpServlet.java:725) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:431) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340) javax.servlet.http.HttpServlet.service(HttpServlet.java:725) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 注意 原因のすべてのスタックトレースは、Apache Tomcat/8.0.20のログに記録されています -------------------------------------------------------------------------------- Apache Tomcat/8.0.20
###該当のソースコード
<%@ page contentType="text/html; charset=UTF-8" import="java.sql.*,javax.naming.*,javax.sql.*,java.text.*,javax.servlet.http.HttpSession"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%> <html> <sql:setDataSource var="db" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost/Library" user="root" password="" /> <sql:query var="rs" dataSource="${db}"> SELECT book.book_no,book.book_name,genre.genre_name, lend.lend_date,book.state FROM book LEFT JOIN lend ON book.book_no = lend.book_no LEFT JOIN user ON user.user_no = lend.user_no LEFT JOIN genre ON book.genre_no = genre.genre_no <c:if test="${!empty param['genreNo']}"> where book.genre_no = ? <sql:param value="${param['genreNo']}" /> </c:if> ORDER BY book.book_no; </sql:query> <sql:query var="rs1" dataSource="${db}"> select * from genre </sql:query> <head> <link rel="stylesheet" type="text/css" href="css/Library.css"> <meta content="text/html; charset=UTF-8"> <title>書籍管理画面</title> </head> <body> <h2>書籍管理画面</h2> <br> <form method="POST" action="book_kanri.jsp"> <% Connection con = null; PreparedStatement ps = null; String sql = null; ResultSet rs = null; try { Context initContext = new InitialContext(); DataSource ds = (DataSource) initContext .lookup("java:comp/env/jdbc/Library"); con = ds.getConnection(); sql = "SELECT book.book_no,book.book_name,genre.genre_name,book.state" + " FROM book LEFT JOIN genre ON book.genre_no = genre.genre_no where delete_flg = 0"; ps = con.prepareStatement(sql); rs = ps.executeQuery(); %> <p> ジャンル <select name="genreno"> <option value="">全て</option> <c:forEach var="row" items="${rs1.rows}"> <option value=${row.genre_no}>${row.genre_name}</option> </c:forEach> </select> <button style="color: white; background-color: D57200;" class="button" type="submit">絞り込む</button> </p> </form> <br> <table class="tbl_01" border="1"> <tr> <th>書籍ID</th> <th>書籍名</th> <th>ジャンル</th> <th>貸出</th> <th>貸出変更</th> <th>削除</th> </tr> <tr> <% while (rs.next()) { %> <td><%=rs.getString("book_no")%></td> <td><%=rs.getString("book_name")%></td> <td><%=rs.getString("genre_name")%></td> <td> <% String str = rs.getString("state"); if ("1".equals(str)) { %>○<% } else { %>×<% } %> </td> <% if ("1".equals(str)) { %><td><form method="POST" action="kano"> <input type="hidden" name="id" value="<%=rs.getString("book_no")%>"> <button class="button" type="submit">不可へ</button> </form></td> <% } else { %> <td><form method="POST" action="huka"> <input type="hidden" name="id" value="<%=rs.getString("book_no")%>"> <button class="button" type="submit">可能へ</button> </form></td> <% } %> <td><form method="POST" action="delete_book"> <input type="hidden" name="id" value="<%=rs.getString("book_no")%>"> <button class="button" type="submit">削除</button> </form></td> </tr> <% } %> </table> <br> <form action="kanri_mypage.jsp"> <input style="color: white; background-color: D57200;" type="submit" name="mypage" value="TOPページ"> </form> <% } catch (Exception e) { throw new ServletException(e); } finally { try { if (rs != null) { rs.close(); } if (ps != null) { ps.close(); } if (con != null) { con.close(); } } catch (Exception e) { } } %> <c:if test="${!empty requestScope['errorMessage']}"> <div>${requestScope['errorMessage']}</div> </c:if> </body> </html>
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/06/17 05:59