java - ERROR SchemaUpdate:237 - near "from": syntax error -


i new spring, , wondering these errors mean?

error schemaupdate:236 - hhh000388: unsuccessful: create table facebookposts (id  integer, created_time timestamp not null, varchar not null, message varchar not null, picture_url varchar not null, post_id varchar not null, varchar not null, updated_time timestamp not null, primary key (id)) error schemaupdate:237 - near "from": syntax error 

i using spring social's facebook library recent posts , store them in sqlite database.

my code follows:

facebookcontrolller

package adam.social.media.controller;  import java.util.hashmap; import java.util.map;  import org.apache.log4j.logger; import org.springframework.beans.factory.annotation.autowired; import org.springframework.social.facebook.api.facebook; import org.springframework.social.facebook.api.post; import org.springframework.social.facebook.api.impl.facebooktemplate; import org.springframework.stereotype.controller; import org.springframework.validation.bindingresult; import org.springframework.web.bind.annotation.requestmapping; import org.springframework.web.bind.annotation.requestmethod; import org.springframework.web.servlet.modelandview;  import adam.social.media.model.facebookmodel; import adam.social.media.repository.facebookrepository;  @controller public class facebookcontroller {         private facebook facebook;      private facebookrepository facebookrepository;      private static logger logger = logger.getlogger(facebookcontroller.class             .getname());      @autowired     public facebookcontroller(facebookrepository facebookrepository) {         logger.debug("entering facebookcontroller");          this.facebookrepository = facebookrepository;                         facebook = new facebooktemplate("caacedeose0cbagjdhb17dtds4vjdhul5ypxqppywdktda963rn4rvzboufatylxcfzkf8aejl0c4cbvtr2og0vjwb7bsbstq71slzhb6d4cvglmzjyi5krayszcflj6tifvhwfmzahzyadnywii3z7p5x8jpovducxsr8pxmeqyeifnh46s5h0p1szuol6usdeqlaf3zap5eswtqs8gqg3loslfksx4zd");                        logger.debug("exiting facebookcontroller");     }      @requestmapping(method = requestmethod.get)     public modelandview getfacebookstatus(facebookmodel facebookmodel) {         logger.debug("entering getfacebookstatus");          modelandview modelandview = new modelandview("index");                post post = facebook.feedoperations().getfeed().get(0);          facebookmodel.setpostid(post.getid());         facebookmodel.setto(post.getto().get(0).getname());         facebookmodel.setfrom(post.getfrom().getname());         facebookmodel.setcreatedtime(post.getcreatedtime());         facebookmodel.setupdatedtime(post.getupdatedtime());         facebookmodel.setmessage(post.getmessage());         facebookmodel.setpictureurl(post.getpicture());          modelandview.addobject("facebookmodel", facebookmodel);          logger.debug("exiting getfacebookstatus");          return modelandview;     }      @requestmapping(method = requestmethod.post)     public modelandview postfacebookstatus(facebookmodel facebookmodel, bindingresult result) {         logger.debug("entering postfacebookstatus");          if (result.haserrors()) {             map<string, object> params = new hashmap<string, object>();              params.put("facebookmodel", facebookmodel);              return new modelandview("index", params);         }          facebookrepository.saveandflush(facebookmodel);          logger.debug("exiting postfacebookstatus");          return new modelandview("redirect:/index.html");     } } 

facebookmodel

package adam.social.media.model;  import java.io.serializable; import java.util.date;  import javax.persistence.column; import javax.persistence.entity; import javax.persistence.generatedvalue; import javax.persistence.generationtype; import javax.persistence.id;  import org.apache.log4j.logger;  @entity(name = "facebookposts") public class facebookmodel implements serializable {      private static final long serialversionuid = -1l;      private static logger logger = logger.getlogger(facebookmodel.class.getname());      @id     @generatedvalue(strategy = generationtype.auto)     private int id;     @column(name = "post_id", nullable = false)     private string postid;     @column(name = "to", nullable = false)     private string to;     @column(name = "from", nullable = false)     private string from;     @column(name = "created_time", nullable = false)     private date createdtime;     @column(name = "updated_time", nullable = false)     private date updatedtime;     @column(name = "message", nullable = false)     private string message;     @column(name = "picture_url", nullable = false)     private string pictureurl;      public int getid() {         return id;     }      public void setid(int id) {         logger.debug("entering setid");          this.id = id;          logger.debug("exiting setid");     }      public string getpostid() {         return postid;     }      public void setpostid(string postid) {         logger.debug("entering setpostid");          this.postid = postid;          logger.debug("exiting setpostid");     }      public string getto() {         return to;     }      public void setto(string to) {         logger.debug("entering setto");          this.to = to;          logger.debug("exiting setto");     }      public string getfrom() {         return from;     }      public void setfrom(string from) {         logger.debug("entering setfrom");          this.from = from;          logger.debug("exiting setfrom");     }      public date getcreatedtime() {         return createdtime;     }      public void setcreatedtime(date createdtime) {         logger.debug("entering setcreatedtime");          this.createdtime = createdtime;          logger.debug("exiting setcreatedtime");     }      public date getupdatedtime() {         return updatedtime;     }      public void setupdatedtime(date updatedtime) {         logger.debug("entering setupdatedtime");          this.updatedtime = updatedtime;          logger.debug("exiting setupdatedtime");     }      public string getmessage() {         return message;     }      public void setmessage(string message) {         logger.debug("entering setmessage");          this.message = message;          logger.debug("exiting setmessage");     }      public string getpictureurl() {         return pictureurl;     }      public void setpictureurl(string pictureurl) {         logger.debug("entering setpictureurl");          this.pictureurl = pictureurl;          logger.debug("exiting setpictureurl");     }      public int hashcode() {         final int prime = 31;         int result = 1;         result = prime * result                 + ((createdtime == null) ? 0 : createdtime.hashcode());         result = prime * result + ((from == null) ? 0 : from.hashcode());         result = prime * result + id;         result = prime * result + ((message == null) ? 0 : message.hashcode());         result = prime * result                 + ((pictureurl == null) ? 0 : pictureurl.hashcode());         result = prime * result + ((postid == null) ? 0 : postid.hashcode());         result = prime * result + ((to == null) ? 0 : to.hashcode());         result = prime * result                 + ((updatedtime == null) ? 0 : updatedtime.hashcode());         return result;     }      public boolean equals(object obj) {         if (this == obj) {             return true;         }         if (obj == null) {             return false;         }         if (getclass() != obj.getclass()) {             return false;         }         facebookmodel other = (facebookmodel) obj;         if (createdtime == null) {             if (other.createdtime != null) {                 return false;             }         } else if (!createdtime.equals(other.createdtime)) {             return false;         }         if (from == null) {             if (other.from != null) {                 return false;             }         } else if (!from.equals(other.from)) {             return false;         }         if (id != other.id) {             return false;         }         if (message == null) {             if (other.message != null) {                 return false;             }         } else if (!message.equals(other.message)) {             return false;         }         if (pictureurl == null) {             if (other.pictureurl != null) {                 return false;             }         } else if (!pictureurl.equals(other.pictureurl)) {             return false;         }         if (postid == null) {             if (other.postid != null) {                 return false;             }         } else if (!postid.equals(other.postid)) {             return false;         }         if (to == null) {             if (other.to != null) {                 return false;             }         } else if (!to.equals(other.to)) {             return false;         }         if (updatedtime == null) {             if (other.updatedtime != null) {                 return false;             }         } else if (!updatedtime.equals(other.updatedtime)) {             return false;         }         return true;     }      public string tostring() {         return "facebookmodel [id=" + id + ", postid=" + postid + ", to=" +                 + ", from=" + + ", createdtime=" + createdtime                 + ", updatedtime=" + updatedtime + ", message=" + message                 + ", pictureurl=" + pictureurl + "]";     }    } 

facebookrepository

package adam.social.media.repository;  import org.springframework.data.jpa.repository.jparepository;  import adam.social.media.model.facebookmodel;  public interface facebookrepository extends jparepository<facebookmodel, integer> {  } 

index.jsp

<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>  <head>     <title>social media</title> </head> <body>     <form:form method="post" commandname="facebookmodel">         <form:hidden path="id" />            <form:hidden path="postid" />            <form:hidden path="to" />            <form:hidden path="from" />          <form:hidden path="createdtime" />           <form:hidden path="updatedtime" />           <form:hidden path="message" />           <form:hidden path="pictureurl" />             <input name="submit" type="submit" value="save" />     </form:form> </body> 

mvc-context.xml

<?xml version="1.0" encoding="utf-8"?>   <beans xmlns="http://www.springframework.org/schema/beans"        xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"        xmlns:p="http://www.springframework.org/schema/p"        xmlns:context="http://www.springframework.org/schema/context"        xmlns:mvc="http://www.springframework.org/schema/mvc"        xsi:schemalocation="http://www.springframework.org/schema/beans                             http://www.springframework.org/schema/beans/spring-beans.xsd                            http://www.springframework.org/schema/context                             http://www.springframework.org/schema/context/spring-context.xsd                            http://www.springframework.org/schema/mvc                            http://www.springframework.org/schema/mvc/spring-mvc.xsd">      <context:property-placeholder location="classpath:application.properties" />         <context:component-scan base-package="adam.social.media" />      <mvc:annotation-driven />     <mvc:view-controller path="/index.html" />      <bean id="messagesource" class="org.springframework.context.support.resourcebundlemessagesource"         p:basename="messages"/>      <bean id="connectionfactorylocator" class="org.springframework.social.connect.support.connectionfactoryregistry">         <property name="connectionfactories">             <list>                 <bean class="org.springframework.social.facebook.connect.facebookconnectionfactory">                     <constructor-arg value="1054655621213643" />                     <constructor-arg value="45c95ab39369187fa11b4272632ea4c7" />                                 </bean>             </list>         </property>     </bean>      <mvc:interceptors>             <bean class="org.springframework.web.servlet.i18n.localechangeinterceptor"             p:paramname="locale" />     </mvc:interceptors>      <bean id="localeresolver" class="org.springframework.web.servlet.i18n.sessionlocaleresolver" />      <bean class="org.springframework.web.servlet.view.internalresourceviewresolver">         <property name="prefix"><value>/web-inf/jsp/</value></property>         <property name="suffix"><value>.jsp</value></property>     </bean>  </beans> 

pom.xml

<project xmlns="http://maven.apache.org/pom/4.0.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"   xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">     <modelversion>4.0.0</modelversion>     <groupid>adam.social.media</groupid>     <artifactid>socialmedia</artifactid>     <packaging>war</packaging>     <version>0.0.1-snapshot</version>     <name>social media</name>      <dependencies>         <dependency>             <groupid>org.springframework</groupid>             <artifactid>spring-webmvc</artifactid>             <version>4.0.4.release</version>         </dependency>         <dependency>             <groupid>org.springframework</groupid>             <artifactid>spring-orm</artifactid>             <version>4.0.4.release</version>         </dependency>         <dependency>             <groupid>org.springframework</groupid>             <artifactid>spring-core</artifactid>             <version>4.1.7.release</version>         </dependency>         <dependency>             <groupid>org.springframework</groupid>             <artifactid>spring-web</artifactid>             <version>4.1.6.release</version>         </dependency>         <dependency>             <groupid>org.springframework.social</groupid>             <artifactid>spring-social-core</artifactid>             <version>1.1.2.release</version>         </dependency>         <dependency>             <groupid>org.springframework.social</groupid>             <artifactid>spring-social-facebook</artifactid>             <version>2.0.1.release</version>         </dependency>         <dependency>             <groupid>org.springframework.social</groupid>             <artifactid>spring-social-web</artifactid>             <version>1.1.2.release</version>         </dependency>         <dependency>             <groupid>org.springframework.data</groupid>             <artifactid>spring-data-jpa</artifactid>             <version>1.6.0.release</version>         </dependency>         <dependency>             <groupid>org.hibernate</groupid>             <artifactid>hibernate-entitymanager</artifactid>             <version>4.3.5.final</version>         </dependency>         <dependency>             <groupid>org.hibernate</groupid>             <artifactid>hibernate-validator</artifactid>             <version>5.0.1.final</version>         </dependency>         <dependency>             <groupid>org.hibernate.javax.persistence</groupid>             <artifactid>hibernate-jpa-2.0-api</artifactid>             <version>1.0.1.final</version>         </dependency>         <dependency>             <groupid>javax.servlet</groupid>             <artifactid>javax.servlet-api</artifactid>             <version>3.1.0</version>         </dependency>         <dependency>             <groupid>javax.servlet</groupid>             <artifactid>jstl</artifactid>             <version>1.2</version>         </dependency>         <dependency>             <groupid>javax.validation</groupid>             <artifactid>validation-api</artifactid>             <version>1.1.0.final</version>         </dependency>         <dependency>             <groupid>junit</groupid>             <artifactid>junit</artifactid>             <version>4.11</version>             <scope>test</scope>         </dependency>         <dependency>             <groupid>log4j</groupid>             <artifactid>log4j</artifactid>             <version>1.2.16</version>         </dependency>         <dependency>             <groupid>org.xerial</groupid>             <artifactid>sqlite-jdbc</artifactid>             <version>3.7.2</version>         </dependency>         <dependency>             <groupid>commons-dbcp</groupid>             <artifactid>commons-dbcp</artifactid>             <version>1.2.2</version>         </dependency>     </dependencies>     <build>         <finalname>socialmedia</finalname>         <plugins>             <plugin>                 <groupid>org.apache.maven.plugins</groupid>                 <artifactid>maven-compiler-plugin</artifactid>                 <version>3.0</version>                 <configuration>                     <source>1.6</source>                     <target>1.6</target>                 </configuration>             </plugin>             <plugin>                 <groupid>org.mortbay.jetty</groupid>                 <artifactid>maven-jetty-plugin</artifactid>                 <version>6.1.10</version>             </plugin>         </plugins>   </build> </project> 

thanks in advance!

adam

from reserved word in sqlite. can either use different name (if possible) or quote mentioned in linked url:

if want use keyword name, need quote it. there 4 ways of quoting keywords in sqlite:

  • 'keyword' - keyword in single quotes string literal.
  • "keyword" - keyword in double-quotes identifier.
  • [keyword] - keyword enclosed in square brackets identifier. not standard sql. quoting mechanism used ms access , sql server , included in sqlite compatibility.
  • `keyword` - keyword enclosed in grave accents (ascii code 96) identifier. not standard sql. quoting mechanism used mysql , included in sqlite compatibility.

according jpa spec (you'll need accept license agreement) seems preferred use double quotes:

@column(name = "\"from\"", nullable = false) private string from; 

cf. my related answer more (hibernate , hsql specific) details.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -