--HATA KODU--

log4j:WARN No appenders could be found for logger (org.hibernate.cfg.annotations.Version).
log4j:WARN Please initialize the log4j system properly.
java.lang.Exception: Kayıt eklenemedi.
    at com.test.Em_conf.ekle(Em_conf.java:43)
    at com.test.T_main.main(T_main.java:9)
Caused by: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
    at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:614)
    at org.hibernate.ejb.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:307)
    at com.test.Em_conf.ekle(Em_conf.java:40)
    ... 1 more
Caused by: org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
    at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:90)
    at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
    at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:275)
    at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:266)
    at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167)
    at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
    at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
    at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1027)
    at org.hibernate.ejb.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:304)
    ... 2 more
Caused by: java.sql.BatchUpdateException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.Table1 (sifre, kullaniciadi) values ('c1', 'c1')' at line 1
    at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:2054)
    at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1467)
    at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)
    at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268)
    ... 8 more
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.Table1 (sifre, kullaniciadi) values ('c1', 'c1')' at line 1
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
    at com.mysql.jdbc.Util.getInstance(Util.java:386)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1054)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4187)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4119)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2570)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2731)
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2815)
    at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2155)
    at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2458)
    at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:2006)
    ... 11 more

--src/meta-inf/persistence.xml

    <?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="hibernatetest" transaction-type="RESOURCE_LOCAL">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <class>com.dao.Table1</class>
        <properties>

        <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
                    <property name="hibernate.default_schema" value="test"></property>
                    <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
                    <property name="hibernate.connection.url" value="jdbc:mysql://localhost/test"/>
                    <property name="hibernate.connection.username" value="root"/>
                    <property name="hibernate.connection.password" value="test"/>
        </properties>
    </persistence-unit>
</persistence>

Java Kısım--

@PersistenceContext
    EntityManager eManager=Persistence.createEntityManagerFactory("hibernatetest").createEntityManager();
public T ekle(T obj) throws Exception {
        try {
            getEntityManager().getTransaction().begin();
            getEntityManager().persist(obj);
            getEntityManager().flush();
            getEntityManager().getTransaction().commit();
        } catch (Exception e) {
            throw new Exception("Kayıt eklenemedi.", e);
        }
        return obj;
    }

soruldu: 17 Tem '13, 06:44

alpgul's gravatar image

alpgul
75141819
cevap kabul oranı: 0%

değiştirildi: 17 Tem '13, 07:42

Sorunu çözdüm önceki hatalı persistence.xml dosyasını .war içine deplo ediyormuş bende onu sildim. copy paste ile war içne yapıştırdım aslında kendi otomatik web-inf klasorunu deploy etmesi gerekmiyor mu?(ant ile derliyorum)

(17 Tem '13, 08:34) alpgul alpgul's gravatar image

   Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 
You have an error in your SQL syntax; check the manual that corresponds to your 
MySQL server version for the right syntax to use near '.
Table1 (sifre, kullaniciadi) values ('c1', 'c1')' at line 1

Yukaridaki mesaja göre SQL statementinde bir hata var. Ona bir bakmak lazim.

permanent link

cevaplandı: 17 Tem '13, 10:57

cakiral's gravatar image

cakiral
1.7k224351
cevap kabul oranı: 18%

değiştirildi: 17 Tem '13, 10:58

hhibernate standart veri ekleme metodu ben sql filan yazmıyorum?

(17 Tem '13, 15:55) alpgul alpgul's gravatar image
Cevabınız
toggle preview

Bu soruyu takip et

E-Posta üzerinden:

Üyelik girişi yaptıktan sonra abonelik işlemlerini yapabilirsiniz

RSS üzerinden:

Cevaplar

Cevaplar ve Yorumlar

Yazı Formatlama

  • *italic* ya da _italic_
  • **bold** ya da __bold__
  • link:[text](http://url.com/ "başlık")
  • resim?![alt text](/path/img.jpg "başlık")
  • liste: 1. Foo 2. Bar
  • temel HTML etiketleri de kullanılabilir

Bu sorunun etiketleri:

×109
×86
×6

Soruldu: 17 Tem '13, 06:44

Görüntüleme: 747 kez

Son güncelleme: 17 Tem '13, 15:55

powered by BitNami OSQA