java - Having trouble loading MySQL database via Hibernate in Eclipse -


resolved problem lay jboss standalone.xml file. fat fingered database name - , can't find tables. else seeing error (because found lot of unresolved) driver , database definitions.

i trying load populated mysql database through hibernate in eclipse. know have connected database, because can ping through eclipse. when publish informs me table not found. i'm not sure missed.

see below persistence.xml file:

<?xml version="1.0" encoding="utf-8"?> <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"> <persistence-unit name="test">     <jta-data-source>java:jboss/datasources/cser-ds</jta-data-source>     <class>org.package.nicknames</class>     <properties>         <property name="hibernate.show_sql" value="true"/>         <property name="hibernate.dialect" value="org.hibernate.dialect.mysql5innodbdialect"/>         <property name="hibernate.connection.username" value="db_user"/>         <property name="hibernate.connection.password" value=""/>                    <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.driver"/>         <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/cser_db"/>         <property name="hibernate.hbm2ddl.auto" value="update" />         <property name="hibernate.generate_statistics" value="true" />         <property name="hibernate.archive.autodetection" value="class"/>      </properties>                </persistence-unit> </persistence> 

the entity file:

package org.package.nicknames;  import java.io.serializable; import java.lang.string; import javax.persistence.*;  @entity @table(name="nicknames") public class nicknames implements serializable {     @id     @column(name = "longname", unique = true, nullable = false, length = 50)     private string longname;      @column(name = "shortname", nullable = false, length = 25)     private string shortname;      private static final long serialversionuid = 1l;      public string getname() {         return longname;     }     public void setname(string longname) {         this.longname = longname;     }      public string getshortname() {         return shortname;     }     public void setshortname(string shortname) {         this.shortname = shortname;     }      public static long getserialversionuid() {         return serialversionuid;     }      } 

and error have:

16:16:40,483 info  [org.hibernate.service.jdbc.connections.internal.connectionproviderinitiator] (msc service thread 1-5) hhh000130: instantiating explicit connection provider: org.hibernate.ejb.connection.injecteddatasourceconnectionprovider 16:16:40,674 info  [org.hibernate.dialect.dialect] (msc service thread 1-5) hhh000400: using dialect: org.hibernate.dialect.mysql5innodbdialect 16:16:40,680 info  [org.hibernate.engine.jdbc.internal.lobcreatorbuilder] (msc service thread 1-5) hhh000423: disabling contextual lob creation jdbc driver reported jdbc version [3] less 4 16:16:40,689 info  [org.hibernate.engine.transaction.internal.transactionfactoryinitiator] (msc service thread 1-5) hhh000268: transaction strategy: org.hibernate.engine.transaction.internal.jta.cmttransactionfactory 16:16:40,693 info  [org.hibernate.hql.internal.ast.astquerytranslatorfactory] (msc service thread 1-5) hhh000397: using astquerytranslatorfactory 16:16:40,721 info  [org.hibernate.validator.util.version] (msc service thread 1-5) hibernate validator 4.2.0.final 16:16:40,931 info  [org.hibernate.tool.hbm2ddl.schemaupdate] (msc service thread 1-5) hhh000228: running hbm2ddl schema update 16:16:40,932 info  [org.hibernate.tool.hbm2ddl.schemaupdate] (msc service thread 1-5) hhh000102: fetching database metadata 16:16:40,936 info  [org.hibernate.tool.hbm2ddl.schemaupdate] (msc service thread 1-5) hhh000396: updating schema 16:16:40,941 info  [java.sql.databasemetadata] (msc service thread 1-5) hhh000262: table not found: nicknames 16:16:40,942 info  [java.sql.databasemetadata] (msc service thread 1-5) hhh000262: table not found: nicknames 16:16:40,947 error [org.hibernate.tool.hbm2ddl.schemaupdate] (msc service thread 1-5) hhh000388: unsuccessful: create table nicknames (longname varchar(50) not null unique, shortname varchar(25) not null, primary key (longname)) engine=innodb 16:16:40,948 error [org.hibernate.tool.hbm2ddl.schemaupdate] (msc service thread 1-5) syntax error in sql statement "create table nicknames (longname varchar(50) not null unique, shortname varchar(25) not null, primary key (longname)) engine=[*]innodb "; expected "identifier"; sql statement: create table nicknames (longname varchar(50) not null unique, shortname varchar(25) not null, primary key (longname)) engine=innodb [42001-161] 16:16:40,949 info  [org.hibernate.tool.hbm2ddl.schemaupdate] (msc service thread 1-5) hhh000232: schema update complete 16:16:40,971 info  [org.jboss.weld.deployer] (msc service thread 1-1) jbas016008: starting weld service deployment test.war 16:16:41,578 info  [javax.enterprise.resource.webcontainer.jsf.config] (msc service thread 1-3) initializing mojarra 2.1.7-jbossorg-1 (20120227-1401) context '/test' 16:16:42,445 info  [org.jboss.web] (msc service thread 1-3) jbas018210: registering web context: /test 16:16:42,506 info  [org.jboss.as.server] (deploymentscanner-threads - 2) jbas018559: deployed "test.war" 

remove unique=true, nullable=false . because primary key. need put again.

@id @column(name = "longname") private string longname; 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -