Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5850383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T13:07:59+00:00 2026-05-22T13:07:59+00:00

I had set up hibernate plugin to NetBeans and can not connect to MySQL

  • 0

I had set up hibernate plugin to NetBeans and can not connect to MySQL dbs – the code:

package client;

import org.hibernate.*;
import org.hibernate.cfg.*;
import java.util.*;

public class HiberTest {

  private static SessionFactory sessionFactory;

  private int id;

  public int getId() {
    return this.id;
  }

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

  protected static void setUp() throws Exception {
      // A SessionFactory is set up once for an application
      sessionFactory = new Configuration()
              .configure() // configures settings from hibernate.cfg.xml
              .buildSessionFactory();
  }

  public static void main(String[] args) throws Exception {
    setUp();
    Session session = HibernateUtils.getSessionFactory().openSession();
    session.beginTransaction();
    Query q = session.createQuery("CREATE TABLE test(myInt int not null)");
        List resultList = q.list();
        System.out.println(resultList);
        session.getTransaction().commit();
        session.close();
  }

}

HibernateUtils.class

package client;

import org.hibernate.cfg.*;
import org.hibernate.SessionFactory;

public class HibernateUtils {

    private static final SessionFactory sessionFactory = buildSessionFactory();
    private static SessionFactory buildSessionFactory() {
        try {
            // Create the SessionFactory from hibernate.cfg.xml
            return new Configuration().configure().buildSessionFactory();
        } catch (Throwable ex) {
            // Make sure you log the exception, as it might be swallowed
            System.err.println("Initial SessionFactory creation failed." + ex);
            throw new ExceptionInInitializerError(ex);
        }
    }
    public static SessionFactory getSessionFactory() {
        return sessionFactory;
    }

}

The errors:

May 22, 2011 12:40:33 PM org.hibernate.hql.ast.ErrorCounter reportError
SEVERE: line 1:1: unexpected token: CREATE
Exception in thread "main" java.lang.IllegalArgumentException: node to traverse cannot be null!
        at org.hibernate.hql.ast.util.NodeTraverser.traverseDepthFirst(NodeTraverser.java:31)
        at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:254)
        at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:157)
        at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)
        at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
        at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:56)
        at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)
        at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
        at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
        at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1623)
        at client.HiberTest.main(HiberTest.java:36)
Java Result: 1

Please help me with this that is a drag for me to deal with hibernate.
After all cfg changes I desided to post cfg.xml and hbm.xml may be someone would suggest something here they are:
cfg.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
  <session-factory>
    <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
    <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
    <property name="hibernate.connection.url">jdbc:mysql://myhost:3306/wwwgeeksearthcom_geeksearth_test</property>
    <property name="hibernate.connection.username">user_name</property>
    <property name="hibernate.connection.password">**********</property>
    <property name="hibernate.show_sql">true</property>
    <!--<property name="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTransactionFactory</property>-->
    <mapping resource="hibernate.hbm.xml"/>
  </session-factory>
</hibernate-configuration>

and hbm.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="HiberTest" table="guests">
  <id name="id" column="g_id">
      <generator class="native"/>
  </id>
</class>
</hibernate-mapping>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T13:07:59+00:00Added an answer on May 22, 2026 at 1:07 pm

    the log already said that the <class> inside the mapping file hibernate.hbm.xml is not properly formatted because of the following error :

    The content of element type “class” is
    incomplete, it must match
    “(meta*,subselect?,cache?,synchronize*,comment?,tuplizer*,(id|composite-id),discriminator?,natural-id?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|properties|any|map|set|list|bag|idbag|array|primitive-array),((join,subclass*)|joined-subclass*|union-subclass*),loader?,sql-insert?,sql-update?,sql-delete?,filter*,resultset*,(query|sql-query)*)”

    This error message means that you violate some requirements of the <class> , for example:

    • It can only contain the child elements listed inside the parenthese
    • The * sign means that child element can occur zero or more times.
    • The ? sign means that child element can occur zero or one time.
    • Without any * and ? sign , that child element must be included and included only once (e.g. id )

    You can refer to this to know how to read the DTD elements syntax.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I had a problem with set not working in a batch file; it took
I've set hibernate.generate_statistics=true and now need to register the mbeans so I can see
I am using Hibernate 3.0.5, Java 6, MySQL 5.5. I thought I had everything
I had set up a bunch of NUnit unit tests using the Test connection
I had set up the MvcBuildViews element to true so my MVC 3 project
Due to some rather bizarre architectural considerations I've had to set up something that
If you had two snippets: (global-set-key \C-d delete-char) and (define-key global-map \C-d delete-char) Is
If a set of controls on a WinForm have had DataBindings created and attached
Currently I had 2 different schema set (setA/ and setB/) sitting under multicore/ folder
If I had a java application that needed specific environment variables to be set,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.