protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
connection.connect.connection();
response.setContentType("text/html");
Integer rating;
String feedback, sql;
PreparedStatement insert;
RequestDispatcher reqdisp;
try {
connection.connect.con.setAutoCommit(false);
rating = Integer.parseInt(request.getParameter("rating"));
feedback = request.getParameter("feedback").trim();
sql = "update Message set rating=?, feedback=? WHERE mid=LAST_INSERT_ID()";
insert = connection.connect.con.prepareStatement(sql);
insert.setObject(1, rating);
insert.setObject(2, feedback);
insert.executeUpdate();
JOptionPane.showMessageDialog(null, "Successfully inserted");
connection.connect.con.commit();
connection.connect.con.close();
} catch (Exception e) {
System.out.println(e);
if (connection.connect.con != null) {
try {
connection.connect.con.rollback();
connection.connect.con.close();
} catch (SQLException ex) {
JOptionPane.showMessageDialog(null, "Error");
}
}
}
reqdisp = getServletContext().getRequestDispatcher("/thankYou.jsp");
reqdisp.forward(request, response);
}
このコードはエラーは発生しませんが、テーブルは更新されません。誰かが私のMySQLクエリで問題を見つけるのを助けることができますか?ありがとうございました!サーブレット(java)からMySQLへのテーブルの更新
Jun 20, 2017 12:29:09 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:Messages' did not find a matching property.
Jun 20, 2017 12:29:09 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:TestingJSP' did not find a matching property.
Jun 20, 2017 12:29:09 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:JQueryAjaxDemo' did not find a matching property.
Jun 20, 2017 12:29:09 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version: Apache Tomcat/9.0.0.M21
Jun 20, 2017 12:29:09 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server built: May 4 2017 22:42:36 UTC
Jun 20, 2017 12:29:09 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server number: 9.0.0.0
Jun 20, 2017 12:29:09 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Name: Mac OS X
Jun 20, 2017 12:29:09 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Version: 10.12.5
Jun 20, 2017 12:29:09 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Architecture: x86_64
Jun 20, 2017 12:29:09 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Java Home: /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre
Jun 20, 2017 12:29:09 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Version: 1.8.0_131-b11
Jun 20, 2017 12:29:09 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Vendor: Oracle Corporation
Jun 20, 2017 12:29:09 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_BASE: /Users/rosemary/Documents/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0
Jun 20, 2017 12:29:09 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_HOME: /opt/apache-tomcat-9.0.0.M21
Jun 20, 2017 12:29:09 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.base=/Users/rosemary/Documents/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0
Jun 20, 2017 12:29:09 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.home=/opt/apache-tomcat-9.0.0.M21
Jun 20, 2017 12:29:09 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dwtp.deploy=/Users/rosemary/Documents/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps
Jun 20, 2017 12:29:09 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.endorsed.dirs=/opt/apache-tomcat-9.0.0.M21/endorsed
Jun 20, 2017 12:29:09 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dfile.encoding=UTF-8
Jun 20, 2017 12:29:09 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/Users/rosemary/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.]
Jun 20, 2017 12:29:10 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-nio-8080"]
Jun 20, 2017 12:29:10 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
Jun 20, 2017 12:29:10 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-nio-8009"]
Jun 20, 2017 12:29:10 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
Jun 20, 2017 12:29:10 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1553 ms
Jun 20, 2017 12:29:10 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service [Catalina]
Jun 20, 2017 12:29:10 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/9.0.0.M21
Jun 20, 2017 12:29:11 PM org.apache.jasper.servlet.TldScanner scanJars
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
Jun 20, 2017 12:29:11 PM org.apache.jasper.servlet.TldScanner scanJars
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
Jun 20, 2017 12:29:11 PM org.apache.jasper.servlet.TldScanner scanJars
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
Jun 20, 2017 12:29:11 PM org.apache.jasper.servlet.TldScanner scanJars
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
Jun 20, 2017 12:29:11 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-nio-8080"]
Jun 20, 2017 12:29:11 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-nio-8009"]
Jun 20, 2017 12:29:11 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 1488 ms
Tue Jun 20 12:29:18 BST 2017 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
Tue Jun 20 12:29:26 BST 2017 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
ここには何も例外はありません。タイムアウトになります。評価のMySQLの値はintで、フィードバックはvarcharです。
キャッチブロックの様子は? – Jens
常に最後に挿入されたレコードを更新するのはなぜですか?複数のユーザーがいる場合は、レコードが更新されることは決してありません。 – Jens
これは小さな内部プロジェクトなので、一度に1人のユーザーしか使用しません。 – Rosemary