We help IT Professionals succeed at work.
Get Started

JSP MySQL 500 error

randyzapata
randyzapata asked
on
514 Views
Last Modified: 2011-10-03
Can someone help me fix this error.

HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Cannot convert value '0000-00-00 00:00:00' from column 10 to TIMESTAMP.
      org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:848)
      org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:781)
      org.apache.jsp.search_jsp._jspService(org.apache.jsp.search_jsp:155)
      org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

java.sql.SQLException: Cannot convert value '0000-00-00 00:00:00' from column 10 to TIMESTAMP.
      com.mysql.jdbc.ResultSet.getTimestampFromString(ResultSet.java:6368)
      com.mysql.jdbc.ResultSet.getStringInternal(ResultSet.java:2162)
      com.mysql.jdbc.ResultSet.getString(ResultSet.java:2077)
      com.mysql.jdbc.ResultSet.getString(ResultSet.java:2195)
      org.apache.jsp.search_jsp._jspService(org.apache.jsp.search_jsp:127)
      org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


note The full stack trace of the root cause is available in the Apache Tomcat/5.5.9 logs.

*****************************

CREATE TABLE logs (Counter int not null auto_increment,
primary key (Counter),
Entered TIMESTAMP,
Title VARCHAR (80),
Salutation VARCHAR (5),
INUM VARCHAR (50),
TrainerName VARCHAR (80),
logType VARCHAR (50),
logNumber VARCHAR (50),
Country VARCHAR (80),
StartTime DATETIME,
StopTime DATETIME,
ContactedName  VARCHAR (80),
ContactedRelationship VARCHAR (30),
AdditionalInfo VARCHAR (255));


*******************************


<%@ page language="java" import="java.sql.*" %>
<HTML>
      <HEAD>
            <TITLE>Trainer</TITLE>
            <META http-equiv="UrlId" content="com.sun.sunit.sdlc.content.RegisterWebPageInfo">
            <META http-equiv="content-type" content="text/html; charset=iso-8859-1">
            <LINK title="JSCstyle" href="AdminScripts/jscdscstyle.css" type="text/css" rel="Stylesheet">
                  <META content="MSHTML 6.00.2800.1498" name="GENERATOR"></HEAD>
      <BODY bgColor="#ffffff" leftMargin="0" topMargin="0" rightMargin="0" marginwidth="0" marginheight="0">
      
      <%
      // define variables
      String Counter;
      String TIMESTAMP;
      String Title;
      String Salutation;
      String INUM;
      String TrainerName;
      String logType;
      String logNumber;
      String Country;                        
      String StartTime;            
      String StopTime;
      String ContactedName;
      String ContactedRelationship;
      String AdditionalInfo;      
      %>
                  
            <SCRIPT src="" type="text/JavaScript"></SCRIPT>
            <DIV class="vnv1" id="vnv1v0">
                  <DIV class="cornerTL">
                        <DIV class="cornerTR">
                              <DIV class="cornerBL">
                                    <DIV class="cornerBR">
                                          <DIV class="vnv1search">&nbsp;</DIV>
                                    </DIV>
                              </DIV>
                        </DIV>
                  </DIV>
            </DIV>
            <DIV class="pagetitle">Trainer log Tracking System<SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"></SPAN></DIV> <!-- END PAGETITLE ONE LINE --> <!-- BEGIN WRAPPER TABLE, 2 COLUMN, LEFT/MAIN -->
            <TABLE height="608" cellSpacing="0" cellPadding="10" width="1375" border="0">
                  <TBODY>
                        <TR>
                              <TD vAlign="top" width="55" height="624"></TD>
                              <TD vAlign="top" width="789" height="624"><A name="skip2content"></A>
                                          <!--START TABLE-->
                                          <TABLE height="631" cellSpacing="0" cellPadding="0" width="596" border="0">
                                                <TBODY>
                                                      <TR>
                                                            <TD class="black" width="737" height="321">
                                                            
                                                                        <%

                                                                        Class.forName("org.gjt.mm.mysql.Driver");
                                                                        
                                                                        // pass database parameters to JDBC driver
                                                                        Connection Conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/Trainer?user=root");

                                                                        // query statement
                                                                        Statement SQLStatement = Conn.createStatement();
                                                                        
                                                                        // generate query
                                                                        String Query = "SELECT Counter,TIMESTAMP,Title,Title,Salutation,INUM,TrainerName,logType,logNumber,Country,StartTime,StopTime,ContactedName,ContactedRelationship,AdditionalInfo FROM logs";

                                                                        // get result
                                                                        ResultSet SQLResult = SQLStatement.executeQuery(Query);

                                                                        while(SQLResult.next())
                                                                        {
                                                                        Counter = SQLResult.getString("Counter");
                                                                        TIMESTAMP = SQLResult.getString("TIMESTAMP");
                                                                        
                                                                        Title = SQLResult.getString("Title");
                                                                        Salutation = SQLResult.getString("Salutation");
                                                                        INUM = SQLResult.getString("INUM");
                                                                        TrainerName = SQLResult.getString("TrainerName");
                                                                        logType = SQLResult.getString("logType");
                                                                        logNumber = SQLResult.getString("logNumber");
                                                                        Country = SQLResult.getString("Country");
                                                                        StartTime = SQLResult.getString("StartTime");
                                                                        StopTime = SQLResult.getString("StopTime");
                                                                        ContactedName = SQLResult.getString("ContactedName");
                                                                        ContactedRelationship = SQLResult.getString("ContactedRelationship");
                                                                        AdditionalInfo = SQLResult.getString("AdditionalInfo");

                                                                        out.println("<tr><td>" + Counter + "</td><td>" +  TIMESTAMP + "</td><td>" + Title + "</td><td>" + Salutation + "</td><td>" + INUM + "</td><td>" + TrainerName + "</td><td>" + logType + "</td><td>" + logNumber + "</td><td>" + Country + "</td><td>" + StartTime + "</td><td>" + StopTime + "</td><td>" + ContactedName + "</td><td>" + ContactedRelationship + "</td><td>" + AdditionalInfo + "</td></tr>");                                                                         }
                                                                        
                                                                        // close connection
                                                                        SQLStatement.close();
                                                                        Conn.close();

                                                                        %>
                                                                        
                                                            </TD>
                                                      </TR>
                                                </TBODY></TABLE>
                              </TD>
                        </TR>
                  </TBODY></TABLE>
      </BODY>
</HTML>

Comment
Watch Question
CERTIFIED EXPERT
Top Expert 2004
Commented:
This problem has been solved!
Unlock 2 Answers and 8 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE