Пробую из Eclipse(Neon), Maven сборщик соединить Hibernate + MySQL

145
11 января 2017, 01:24

Вот структура проекта

POM.XML

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
  <modelVersion>4.0.0</modelVersion> 
  <groupId>maven-jar-hibernate</groupId> 
  <artifactId>maven-jar-hibernate</artifactId> 
  <version>0.0.1-SNAPSHOT</version> 
  <packaging>jar</packaging> 
  <name>by.edu.java.buglak</name> 
  <description>maven jar hibernate test project</description> 
  <build> 
    <plugins> 
    <plugin> 
		<artifactId>maven-jar-plugin</artifactId> 
		<version>2.4</version> 
		<configuration> 
			<archive> 
				<manifest> 
					<mainClass>Main</mainClass> 
				</manifest> 
			</archive> 
		</configuration> 
		</plugin> 
		<plugin> 
			<groupId>org.apache.maven.plugins</groupId> 
			<artifactId>maven-javadoc-plugin</artifactId> 
			<version>2.9</version> 
		</plugin> 
      <plugin> 
        <artifactId>maven-compiler-plugin</artifactId> 
        <version>3.5.1</version> 
        <configuration> 
          <source>1.8</source> 
          <target>1.8</target> 
        </configuration> 
      </plugin> 
    </plugins> 
  </build> 
  <dependencies> 
	<dependency> 
    	<groupId>org.hibernate</groupId> 
    	<artifactId>hibernate-core</artifactId> 
    	<version>5.2.5.Final</version> 
	</dependency> 
	<dependency> 
	    <groupId>org.hibernate</groupId> 
	    <artifactId>hibernate-entitymanager</artifactId> 
	    <version>5.2.5.Final</version> 
	</dependency> 
	<dependency> 
	    <groupId>org.hibernate</groupId> 
	    <artifactId>hibernate-validator</artifactId> 
	    <version>5.3.4.Final</version> 
	</dependency> 
	<dependency> 
	    <groupId>mysql</groupId> 
	    <artifactId>mysql-connector-java</artifactId> 
	    <version>5.1.40</version> 
	</dependency> 
  </dependencies> 
</project>

HIBERNATE.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.connection.driver_class">com.mysql.jdbc.Driver</property> 
        <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/hibernate</property> 
        <property name="hibernate.connection.username">root</property> 
        <property name="hibernate.connection.password">12345</property> 
        <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property> 
        <property name="hibernate.connection.pool_size">10</property> 
        <property name="show_sql">true</property> 
        <property name="hibernate.hbm2ddl.auto">update</property> 
    </session-factory> 
</hibernate-configuration>

HibernateUtil.java

import org.hibernate.SessionFactory; 
import org.hibernate.boot.registry.StandardServiceRegistryBuilder; 
import org.hibernate.cfg.Configuration; 
 
public class HibernateUtil { 
	private static SessionFactory sessionFactory = null; 
 
	static { 
		Configuration cfg = new Configuration().configure(); 
		StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder().applySettings(cfg.getProperties()); 
		try { 
			sessionFactory = cfg.buildSessionFactory(builder.build()); 
		} catch (Exception ex) { 
			System.out.println(ex.getMessage()); 
		} 
	} 
 
	public static SessionFactory getSessionFactory() { 
		return sessionFactory; 
	} 
}

Main.java

import org.hibernate.SessionFactory; 
 
public class Main { 
	public static void main(String[] args) { 
		SessionFactory sessionFactory = HibernateUtil.getSessionFactory(); 
	} 
}

Console Eclipse

янв 06, 2017 11:03:23 PM org.hibernate.Version logVersion 
INFO: HHH000412: Hibernate Core {5.2.5.Final} 
янв 06, 2017 11:03:23 PM org.hibernate.cfg.Environment <clinit> 
INFO: HHH000206: hibernate.properties not found 
янв 06, 2017 11:03:23 PM org.hibernate.boot.jaxb.internal.stax.LocalXmlResourceResolver resolveEntity 
WARN: HHH90000012: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/hibernate-configuration. Use namespace http://www.hibernate.org/dtd/hibernate-configuration instead.  Support for obsolete DTD/XSD namespaces may be removed at any time. 
янв 06, 2017 11:03:23 PM org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit> 
INFO: HCANN000001: Hibernate Commons Annotations {5.0.1.Final} 
янв 06, 2017 11:03:23 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure 
WARN: HHH10001002: Using Hibernate built-in connection pool (not for production use!) 
янв 06, 2017 11:03:23 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator 
INFO: HHH10001005: using driver [com.mysql.jdbc.Driver] at URL [jdbc:mysql://localhost:3306/hibernate] 
янв 06, 2017 11:03:23 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator 
INFO: HHH10001001: Connection properties: {user=root, password=****} 
янв 06, 2017 11:03:23 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator 
INFO: HHH10001003: Autocommit mode: false 
янв 06, 2017 11:03:23 PM org.hibernate.engine.jdbc.connections.internal.PooledConnections <init> 
INFO: HHH000115: Hibernate connection pool size: 10 (min=1) 
янв 06, 2017 11:03:24 PM org.hibernate.dialect.Dialect <init> 
INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect 
янв 06, 2017 11:03:24 PM org.hibernate.validator.internal.util.Version <clinit> 
INFO: HV000001: Hibernate Validator 5.3.4.Final 
янв 06, 2017 11:03:24 PM org.hibernate.resource.transaction.backend.jdbc.internal.DdlTransactionIsolatorNonJtaImpl getIsolatedConnection 
INFO: HHH10001501: Connection obtained from JdbcConnectionAccess [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess@5a7fe64f] for (non-JTA) DDL execution was not in auto-commit mode; the Connection 'local transaction' will be committed and the Connection will be set into auto-commit mode.

Если в hibernate.cfg.xml параметр hibernate.hbm2ddl.auto=create то в Console последние строчки буд иметь вид

INFO: HHH000115: Hibernate connection pool size: 10 (min=1) 
янв 06, 2017 11:10:47 PM org.hibernate.dialect.Dialect <init> 
INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect 
янв 06, 2017 11:10:48 PM org.hibernate.validator.internal.util.Version <clinit> 
INFO: HV000001: Hibernate Validator 5.3.4.Final 
янв 06, 2017 11:10:48 PM org.hibernate.tool.schema.internal.SchemaCreatorImpl applyImportSources 
INFO: HHH000476: Executing import script 'org.hibernate.tool.schema.internal.exec.ScriptSourceInputNonExistentImpl@5276d6ee'

Помогите пожалуйста. Что я делаю не так? Как мне добиться корректного соединения Hibernate+MySQL из Eclipse(Neon)? Заранее спасибо! ...

READ ALSO
Подстановка Конвертера Валют на сайт

Подстановка Конвертера Валют на сайт

Ребят, подскажите пожалуйстаЕсть некий код, собирающий данные определенной страны в шапке на сайте:

106
FAILED BINDER TRANSACTION

FAILED BINDER TRANSACTION

Передаю объект своего класса (реализую Parcelable) из одного активити в другое через IntentИз второго активити в фрагмент расположенный на этой активити...

137
без причины вызывается метод repaint()

без причины вызывается метод repaint()

Создал JPanel на котором есть 3 кнопки, и овал, нарисованный в методе paintComponent()По задумке, при нажатии на одну из кнопок, она обводится в рамочку,...

114