2016-06-02 4 views
1

- 私へのアクセスが、私は、このエラーメッセージを取得:エラーメッセージ:エラー休止状態を使用してMySQLデータベースのテーブルを作成しようとSTAXストリーム

Exception in thread "main" org.hibernate.HibernateException: Error accessing stax stream 
    at org.hibernate.boot.cfgxml.internal.JaxbCfgProcessor.unmarshal(JaxbCfgProcessor.java:107) 
    at org.hibernate.boot.cfgxml.internal.JaxbCfgProcessor.unmarshal(JaxbCfgProcessor.java:65) 
    at org.hibernate.boot.cfgxml.internal.ConfigLoader.loadConfigXmlResource(ConfigLoader.java:57) 
    at org.hibernate.boot.registry.StandardServiceRegistryBuilder.configure(StandardServiceRegistryBuilder.java:163) 
    at org.hibernate.cfg.Configuration.configure(Configuration.java:259) 
    at com.anika.hibernate.Main.main(Main.java:18) 
Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[2,34] 

これを「メイン」org.hibernate.HibernateExceptionスレッドでの例外答えは私の問題を解決していない:Error connecting with database using hibernate

Exception in thread "main" org.hibernate.HibernateException: Error accessing stax stream

これは私のMain.javaファイルです:

package com.anika.hibernate; 

import org.hibernate.Session; 
import org.hibernate.SessionFactory; 
import org.hibernate.cfg.Configuration; 



public class Main { 

    public static void main(String[] args){ 

    Student_Info student = new Student_Info(); 

    student.setName("Anika"); 
    student.setRollNo(1); 

    SessionFactory sessionFactory = new Configuration().configure("hibernate.cfg.xml").buildSessionFactory(); 
    Session session = sessionFactory.openSession(); 
    session.beginTransaction(); 

    session.save(student); 

    session.getTransaction().commit(); 
    session.close(); 
    sessionFactory.close(); 


    } 

} 

私はhibernate.cfg.xml:

<?xml version='1.0' encoding='utf-8'?> 
<DOCTYPE hibernate-configuration PUBLIC 
     "-//Hibernate/Hibernate Configuration DTD 3.0//EN" 
     "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> 

<!-- 
    ~ Hibernate, Relational Persistence for Idiomatic Java 
    ~ 
    ~ License: GNU Lesser General Public License (LGPL), version 2.1 or later. 
    ~ See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. 
    --> 
<hibernate-configuration 

    <session-factory> 
    <!-- Database connection settings --> 
    <property name="connection.driver_class">com.mysql.jdbc.Driver</property> 
    <property name="connection.url">jdbc:mysql://localhost:3306/hibernatetutorials</property> 
    <property name="connection.username">root</property> 
    <property name="connection.password"></property> 

    <!-- JDBC connection pool (use the built-in) --> 
    <property name="connection.pool_size">1</property> 

    <!-- SQL dialect --> 
    <property name="dialect">org.hibernate.dialect.MySQLDialect</property> 


    <!-- Disable the second-level cache --> 
    <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property> 

    <!-- Echo all executed SQL to stdout --> 
    <property name="show_sql">true</property> 

    <!-- Drop and re-create the database schema on startup --> 
    <property name="hbm2ddl.auto">create</property> 
    <mapping class="com.anika.hibernate.Stundent_Info"/> 
    </session-factory> 
</hibernate-configuration> 

あなたがタグ<hibernate-configurationを閉じる必要があり、あなたの助けを

答えて

0

、ありがとうございました。

<hibernate-configuration>

DOCTYPE!文字がありません:

<DOCTYPE hibernate-configuration PUBLIC 
     "-//Hibernate/Hibernate Configuration DTD 3.0//EN" 
     "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> 

は、私は同じ問題に直面して

<!DOCTYPE hibernate-configuration PUBLIC 
    "-//Hibernate/Hibernate Configuration DTD 3.0//EN" 
    "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> 
+0

ありがとうございます。私はまだ同じエラーメッセージを受け取ります。 – Anika

+0

@Anika私は更新します。 –

+0

ありがとうございます。これはうまく動作します。 – Anika

1

であるべき。システムは、提供されたURLからhibernate-configuration-3.0.dtdにアクセスすることができません。

<DOCTYPE hibernate-configuration PUBLIC 
    "-//Hibernate/Hibernate Configuration DTD 3.0//EN" 
    "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> 

私はローカルシステムから参照しました。

<!DOCTYPE hibernate-configuration SYSTEM 
    "classpath://org/hibernate/hibernate-configuration-3.0.dtd"> 

私にとってはうまくいった。それが役に立てば幸い!

関連する問題