[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - could not insert exception in JBOSS 4.2.2 GA ...

sajhak do-not-reply at jboss.com
Wed Mar 19 10:09:27 EDT 2008


Hi all , 

im testing en Entity ( named as BookBank ) , using MySQL.

I tested with the default database(HSQL) , and it succeeded.
But when i configure the database to MySQL , it throws the following exception ..
( i placed connection pool config file "booksdb-ds.xml" in to the deploy directory of JBOSS and the 

mySQL-J connector jar file to the lib directory )
when i used with HSQL the -ds.xml file had following properties

  
            
            
        

 , those properties  i didnt include in the booksdb-ds.xml file..
is that the cause of the problem ?

pls help 

i have attached my Entity class ,  persistence.xml and part of the booksdb-ds.xml files for your consideration ...

also please give me a good resource of "EJB3 persistance , how the configurations should be done in JBOSS , etc etc .."  for a beginner 

thanks in advance
Saji


19:25:30,000 WARN  [JDBCExceptionReporter] SQL Error: 1146, SQLState: 42S02
19:25:30,000 ERROR [JDBCExceptionReporter] Table 'b04042.bookbank' doesn't exist

19:25:30,062 ERROR [STDERR] javax.ejb.EJBException: javax.persistence.Persistenc
eException: org.hibernate.exception.SQLGrammarException: could not insert: [dev.
saji.ejb.bean.entity.BookBank]
19:25:30,062 ERROR [STDERR]     at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptio
nInOurTx(Ejb3TxPolicy.java:63)
19:25:30,062 ERROR [STDERR]     at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(T
xPolicy.java:83)
19:25:30,062 ERROR [STDERR]     at org.jboss.aspects.tx.TxInterceptor$Required.i
nvoke(TxInterceptor.java:191)
19:25:30,062 ERROR [STDERR]     at org.jboss.aop.joinpoint.MethodInvocation.invo
keNext(MethodInvocation.java:101)
19:25:30,062 ERROR [STDERR]     at org.jboss.aspects.tx.TxPropagationInterceptor
.invoke(TxPropagationInterceptor.java:95)
19:25:30,062 ERROR [STDERR]     at org.jboss.aop.joinpoint.MethodInvocation.invo
keNext(MethodInvocation.java:101)




BookBank.java
--------------
package dev.saji.ejb.bean.entity;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;


@Entity
@Table
public class BookBank implements Serializable {

    long id;
    String title;
    String author;
    double price;



    public BookBank() {
        super();
    }

    public BookBank (String title , String author , double price) {
        super();
        this.title = title;
        this.author = author;
        this.price = price;

    }

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }
}
==============================================

persistence.xml
---------------
<?xml version="1.0" encoding="UTF-8"?>

    <persistence-unit name="EntityBean">               
        <jta-data-source>java:/EntityBean</jta-data-source>
        dev.saji.ejb.bean.entity.BookBank
    </persistence-unit>



====================================


  <local-tx-datasource>
    <jndi-name>EntityBean</jndi-name>
    <connection-url>jdbc:mysql://localhost:3306/b04042</connection-url>
	<driver-class>com.mysql.jdbc.Driver</driver-class>
    <user-name>root</user-name>
    sajith

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4137762#4137762

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4137762



More information about the jboss-user mailing list