title: Java hibernate and mysql
body: <p>I'm trying out this hibernate, and following a tutorial on it. However I quickly get stuck on an exception.</p>
  
  <pre><code>public class input {
  
  public static void main(String[] args){
  
      student student = new student();
      student.setName("bar");
      student.setRollNo(1);
  
      SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
      Session session = sessionFactory.openSession();
      session.beginTransaction();
  
      session.save(student);
  
      session.getTransaction().commit();
      session.close();
      sessionFactory.close();
  }
  }
  </code></pre>
  
  <p>my student class</p>
  
  <pre><code>@Entity
  public class student {
  
  @Id
  private int rollNo;
  private String name;
  
  public String getName() {
      return name;
  }
  public void setName(String name) {
      this.name = name;
  }
  public int getRollNo() {
      return rollNo;
  }
  public void setRollNo(int rollNo) {
      this.rollNo = rollNo;
  }
  }
  </code></pre>
  
  <p>UPDATED - console gives:</p>
  
  <pre><code>sep. 23, 2015 3:04:41 PM org.hibernate.Version logVersion
  INFO: HHH000412: Hibernate Core {5.0.0.Final}
  sep. 23, 2015 3:04:41 PM org.hibernate.cfg.Environment &lt;clinit&gt;
  INFO: HHH000206: hibernate.properties not found
  sep. 23, 2015 3:04:41 PM org.hibernate.cfg.Environment buildBytecodeProvider
  INFO: HHH000021: Bytecode provider name : javassist
  Exception in thread "main" org.hibernate.internal.util.config.ConfigurationException: Unable to perform unmarshalling at line number 8 and column 63 in RESOURCE hibernate.cfg.xml. Message: cvc-elt.1: Cannot find the declaration of element 'hibernate-configuration'.
      at org.hibernate.boot.cfgxml.internal.JaxbCfgProcessor.unmarshal(JaxbCfgProcessor.java:135)
      at org.hibernate.boot.cfgxml.internal.JaxbCfgProcessor.unmarshal(JaxbCfgProcessor.java:67)
      at org.hibernate.boot.cfgxml.internal.ConfigLoader.loadConfigXmlResource(ConfigLoader.java:55)
      at org.hibernate.boot.registry.StandardServiceRegistryBuilder.configure(StandardServiceRegistryBuilder.java:163)
      at org.hibernate.cfg.Configuration.configure(Configuration.java:259)
      at org.hibernate.cfg.Configuration.configure(Configuration.java:245)
      at com.test.input.main(input.java:15)
  Caused by: javax.xml.bind.UnmarshalException
   - with linked exception:
  [org.xml.sax.SAXParseException; lineNumber: 8; columnNumber: 63; cvc-elt.1: Cannot find the declaration of element 'hibernate-configuration'.]
      at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamException(UnmarshallerImpl.java:468)
      at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:448)
      at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:420)
      at org.hibernate.boot.cfgxml.internal.JaxbCfgProcessor.unmarshal(JaxbCfgProcessor.java:128)
      ... 6 more
  Caused by: org.xml.sax.SAXParseException; lineNumber: 8; columnNumber: 63; cvc-elt.1: Cannot find the declaration of element 'hibernate-configuration'.
      at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203)
      at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:134)
      at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:437)
      at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:368)
      at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:325)
      at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:1906)
      at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:746)
      at com.sun.org.apache.xerces.internal.jaxp.validation.ValidatorHandlerImpl.startElement(ValidatorHandlerImpl.java:570)
      at com.sun.xml.internal.bind.v2.runtime.unmarshaller.ValidatingUnmarshaller.startElement(ValidatingUnmarshaller.java:86)
      at com.sun.xml.internal.bind.v2.runtime.unmarshaller.InterningXmlVisitor.startElement(InterningXmlVisitor.java:60)
      at com.sun.xml.internal.bind.v2.runtime.unmarshaller.StAXEventConnector.handleStartElement(StAXEventConnector.java:246)
      at com.sun.xml.internal.bind.v2.runtime.unmarshaller.StAXEventConnector.bridge(StAXEventConnector.java:115)
      at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:445)
      ... 8 more
  </code></pre>
  
  <p>I'm not sure what is causing this. I tried to make a normal prepared statement, and suceeded. So I'm nearly sudden it's not my database, or login details that is the problem.</p>
  
  <p>hibernate.cfg.xml file</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; 
  
  &lt;hibernate-configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.hibernate.org/xsd/hibernate-configuration hibernate-configuration-4.0.xsd"
      xmlns="http://www.hibernate.org/xsd/hibernate-configuration"&gt;
  
      &lt;session-factory&gt;
  
          &lt;property name="connection.driver_class"&gt;com.mysql.jdbc.Driver&lt;/property&gt;
  
          &lt;property name="connection.url"&gt;jdbc:mysql://localhost:3306/dbname&lt;/property&gt;
  
          &lt;property name="connection.username"&gt;someuser&lt;/property&gt;
  
          &lt;property name="connection.password"/&gt;somepass&lt;/property&gt;
  
          &lt;property name="connection.pool_size"&gt;1&lt;/property&gt;
  
          &lt;property name="dialect"&gt;org.hibernate.dialect.MySQLDialect&lt;/property&gt;
  
          &lt;property name="current_session_context_class"&gt;thread&lt;/property&gt;
  
          &lt;property name="cache.provider_class"&gt;org.hibernate.cache.internal.NoCacheProvider&lt;/property&gt;
          &lt;property name="show_sql"&gt;true&lt;/property&gt;
  
          &lt;property name="hbm2ddl.auto"&gt;create&lt;/property&gt;
  
          &lt;mapping class="com.test.student"/&gt;
  
      &lt;/session-factory&gt;
  
  &lt;/hibernate-configuration&gt;
  </code></pre>