Boa noite estou tentando fazer conexão com o banco mas o console lança o seguinte erro:
0 [main] INFO org.hibernate.Version - HHH000412: Hibernate Core {5.2.1.Final}
4 [main] INFO org.hibernate.cfg.Environment - HHH000206: hibernate.properties not found
7 [main] INFO org.hibernate.cfg.Environment - HHH000021: Bytecode provider name : javassist
75 [main] WARN org.hibernate.orm.deprecation - 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.
544 [main] INFO org.hibernate.annotations.common.Version - HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
781 [main] WARN org.hibernate.orm.connections - HHH10001002: Using Hibernate built-in connection pool (not for production use!)
804 [main] INFO org.hibernate.orm.connections - HHH10001005: using driver [com.mysql.jdbc.Driver] at URL [jdbc:mysql://localhost/agenda]
805 [main] INFO org.hibernate.orm.connections - HHH10001001: Connection properties: {user=root, password=****}
805 [main] INFO org.hibernate.orm.connections - HHH10001003: Autocommit mode: false
810 [main] INFO org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl - HHH000115: Hibernate connection pool size: 20 (min=1)
Tue Aug 02 20:47:41 BRT 2016 WARN: Establishing SSL connection without server’s identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn’t set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to ‘false’. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
1378 [main] INFO org.hibernate.dialect.Dialect - HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
Exception in thread “main” java.lang.NullPointerException
at com.livro.capitulo3.conexao.ConectaHibernateMySQL.main(ConectaHibernateMySQL.java:17)
implementei o código sugerido por você e o erro agora é esse:
1 [main] INFO org.hibernate.Version - HHH000412: Hibernate Core {5.2.1.Final}
5 [main] INFO org.hibernate.cfg.Environment - HHH000206: hibernate.properties not found
7 [main] INFO org.hibernate.cfg.Environment - HHH000021: Bytecode provider name : javassist
74 [main] WARN org.hibernate.orm.deprecation - 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.
568 [main] INFO org.hibernate.annotations.common.Version - HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
802 [main] WARN org.hibernate.orm.connections - HHH10001002: Using Hibernate built-in connection pool (not for production use!)
824 [main] INFO org.hibernate.orm.connections - HHH10001005: using driver [com.mysql.jdbc.Driver] at URL [jdbc:mysql://localhost/agenda]
825 [main] INFO org.hibernate.orm.connections - HHH10001001: Connection properties: {user=root, password=****}
825 [main] INFO org.hibernate.orm.connections - HHH10001003: Autocommit mode: false
832 [main] INFO org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl - HHH000115: Hibernate connection pool size: 20 (min=1)
Sun Aug 21 10:35:46 BRT 2016 WARN: Establishing SSL connection without server’s identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn’t set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to ‘false’. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
1518 [main] INFO org.hibernate.dialect.Dialect - HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
Exception in thread “main” java.lang.NullPointerException
at com.livro.capitulo3.conexao.Conecta.main(Conecta.java:18)
Desculpa me meter na Thread brother, mas seu problema não é com a trasação visto que você não faz nada transacional no momento, você quer apenas conectar, o que falta é passar ao configurator o ser arquivo hibernate.cfg.xml, sugiro dar uma olhada na documentação ela é bem clara, então para resolver ou você passa o ser arquivo ao configurator ou seta tudo na mão na própria classe, ex:
Configuration cfg = new Configuration();
cfg.configure("hibernate.cfg.xml");