Tapestry / JDBC - Storing Date
Posted
by Ben
on Stack Overflow
See other posts from Stack Overflow
or by Ben
Published on 2010-05-31T17:02:27Z
Indexed on
2010/06/01
12:53 UTC
Read the original article
Hit count: 621
So Im using Tapestry and trying to store a date from a beaneditform into a simple Access database. It wont work, Im getting Null pointer exceptions and I cannot understand why.
String onSuccess()
{
System.out.println("in on success!");
String nextPage = null;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
connection = DriverManager.getConnection("jdbc:odbc:FYP_Users");
DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
Date ed = occasion.getEventDate();
String reportDate = df.format(ed);
statement.executeUpdate("INSERT INTO Events (UserName, EventName, EventDate, EventTime, EventDetails, People, Rating) " + "VALUES ('" + login.getUserName() + "', '" + occasion.getEventName()+ "', '" + reportDate + "', '" + occasion.getEventTime() + "', '" + occasion.getEventDetails() + "', '" + occasion.getPeople() + "', '"+ "1" +"')");
connection.close();
occasion = new Occasion();
//occasion.setUserName(occasion.getUserName());
occasion.setEventName(occasion.getEventName());
occasion.setEventDate(occasion.getEventDate());
occasion.setEventTime(occasion.getEventTime());
occasion.setEventDetails(occasion.getEventDetails());
occasion.setPeople(occasion.getPeople());
//occasion.setRating(occasion.getRating());
nextPage = "UserIndex";
}
catch (SQLException e) {e.printStackTrace();}
catch (ClassNotFoundException e) {e.printStackTrace();}
return nextPage;
}
Stack trace
java.util.Calendar.setTime(Unknown Source)
java.text.SimpleDateFormat.format(Unknown Source)
java.text.SimpleDateFormat.format(Unknown Source)
java.text.DateFormat.format(Unknown Source)
myappj.pages.CreateOccasion.onSuccess(CreateOccasion.java:61)
myappj.pages.CreateOccasion.dispatchComponentEvent(CreateOccasion.java)
org.apache.tapestry5.internal.structure.ComponentPageElementImpl.dispatchEvent(ComponentPageElementImpl.java:902)
org.apache.tapestry5.internal.structure.ComponentPageElementImpl.triggerContextEvent(ComponentPageElementImpl.java:1081)
org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl.triggerContextEvent(InternalComponentResourcesImpl.java:263)
org.apache.tapestry5.corelib.components.Form._$advised$onAction(Form.java:398)
org.apache.tapestry5.corelib.components.Form$onAction$invocation_128ef468876.invokeAdvisedMethod(Form$onAction$invocation_128ef468876.java)
org.apache.tapestry5.internal.services.AbstractComponentMethodInvocation.proceed(AbstractComponentMethodInvocation.java:71)
org.apache.tapestry5.ioc.internal.services.LoggingAdvice.advise(LoggingAdvice.java:37)
org.apache.tapestry5.internal.transform.LogWorker$1.advise(LogWorker.java:54)
org.apache.tapestry5.internal.services.AbstractComponentMethodInvocation.proceed(AbstractComponentMethodInvocation.java:80)
org.apache.tapestry5.corelib.components.Form.onAction(Form.java)
org.apache.tapestry5.corelib.components.Form.dispatchComponentEvent(Form.java)
org.apache.tapestry5.internal.structure.ComponentPageElementImpl.dispatchEvent(ComponentPageElementImpl.java:910)
org.apache.tapestry5.internal.structure.ComponentPageElementImpl.triggerContextEvent(ComponentPageElementImpl.java:1081)
org.apache.tapestry5.internal.services.ComponentEventRequestHandlerImpl.handle(ComponentEventRequestHandlerImpl.java:75)
org.apache.tapestry5.internal.services.ImmediateActionRenderResponseFilter.handle(ImmediateActionRenderResponseFilter.java:42)
$ComponentEventRequestHandler_128ef45bf4a.handle($ComponentEventRequestHandler_128ef45bf4a.java)
org.apache.tapestry5.internal.services.AjaxFilter.handle(AjaxFilter.java:42)
$ComponentEventRequestHandler_128ef45bf4a.handle($ComponentEventRequestHandler_128ef45bf4a.java)
org.apache.tapestry5.services.TapestryModule$36.handle(TapestryModule.java:2164)
$ComponentEventRequestHandler_128ef45bf4a.handle($ComponentEventRequestHandler_128ef45bf4a.java)
$ComponentEventRequestHandler_128ef45bea5.handle($ComponentEventRequestHandler_128ef45bea5.java)
org.apache.tapestry5.internal.services.ComponentRequestHandlerTerminator.handleComponentEvent(ComponentRequestHandlerTerminator.java:43)
$ComponentRequestHandler_128ef45be99.handleComponentEvent($ComponentRequestHandler_128ef45be99.java)
org.apache.tapestry5.internal.services.ComponentEventDispatcher.dispatch(ComponentEventDispatcher.java:46)
$Dispatcher_128ef45be9b.dispatch($Dispatcher_128ef45be9b.java)
$Dispatcher_128ef45be92.dispatch($Dispatcher_128ef45be92.java)
org.apache.tapestry5.services.TapestryModule$RequestHandlerTerminator.service(TapestryModule.java:245)
org.apache.tapestry5.internal.services.RequestErrorFilter.service(RequestErrorFilter.java:26)
$RequestHandler_128ef45be93.service($RequestHandler_128ef45be93.java)
org.apache.tapestry5.services.TapestryModule$4.service(TapestryModule.java:778)
$RequestHandler_128ef45be93.service($RequestHandler_128ef45be93.java)
org.apache.tapestry5.services.TapestryModule$3.service(TapestryModule.java:767)
$RequestHandler_128ef45be93.service($RequestHandler_128ef45be93.java)
org.apache.tapestry5.internal.services.StaticFilesFilter.service(StaticFilesFilter.java:85)
$RequestHandler_128ef45be93.service($RequestHandler_128ef45be93.java)
myappj.services.AppModule$1.service(AppModule.java:90)
$RequestFilter_128ef45be8e.service($RequestFilter_128ef45be8e.java)
$RequestHandler_128ef45be93.service($RequestHandler_128ef45be93.java)
org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:90)
org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:81)
org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier.withRead(ConcurrentBarrier.java:85)
org.apache.tapestry5.internal.services.CheckForUpdatesFilter.service(CheckForUpdatesFilter.java:103)
$RequestHandler_128ef45be93.service($RequestHandler_128ef45be93.java)
$RequestHandler_128ef45be88.service($RequestHandler_128ef45be88.java)
org.apache.tapestry5.services.TapestryModule$HttpServletRequestHandlerTerminator.service(TapestryModule.java:197)
org.apache.tapestry5.internal.gzip.GZipFilter.service(GZipFilter.java:53)
$HttpServletRequestHandler_128ef45be8a.service($HttpServletRequestHandler_128ef45be8a.java)
org.apache.tapestry5.internal.services.IgnoredPathsFilter.service(IgnoredPathsFilter.java:62)
$HttpServletRequestFilter_128ef45be87.service($HttpServletRequestFilter_128ef45be87.java)
$HttpServletRequestHandler_128ef45be8a.service($HttpServletRequestHandler_128ef45be8a.java)
org.apache.tapestry5.services.TapestryModule$2.service(TapestryModule.java:726)
$HttpServletRequestHandler_128ef45be8a.service($HttpServletRequestHandler_128ef45be8a.java)
$HttpServletRequestHandler_128ef45be85.service($HttpServletRequestHandler_128ef45be85.java)
org.apache.tapestry5.TapestryFilter.doFilter(TapestryFilter.java:127)
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:722)
org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:404)
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
org.mortbay.jetty.Server.handle(Server.java:324)
org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:842)
org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:648)
org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:450)
© Stack Overflow or respective owner