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 question.(5)

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

ITtutoria

ITtutoria Logo ITtutoria Logo

ITtutoria Navigation

  • Python
  • Java
  • Reactjs
  • JavaScript
  • R
  • PySpark
  • MYSQL
  • Pandas
  • QA
  • C++
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Python
  • Science
  • Java
  • JavaScript
  • Reactjs
  • Nodejs
  • Tools
  • QA
Home/ Questions/Resolved the problem of the unable to create requested service [org.hibernate.engine.jdbc.env.spi.jdbcenvironment]
Next
Answered
Delilah Gelbero
  • 26
Delilah Gelbero
Asked: May 18, 20222022-05-18T18:07:55+00:00 2022-05-18T18:07:55+00:00In: java

Resolved the problem of the unable to create requested service [org.hibernate.engine.jdbc.env.spi.jdbcenvironment]

  • 26

. Advertisement .

..3..

. Advertisement .

..4..

I don’t know what I’m doing wrong, but I’ve already lost a couple of days struggling with this.
Here is my command line:

<?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>
  <!-- Database connection settings -->
  <property name="connection.driver_class">org.postgresql.Driver</property>
  <property name="connection.url">jdbc:postgresql://localhost:5432/hibernatedb</property>
  <property name="connection.username">sa</property>
  <property name="connection.password">password</property>
 
  <!-- JDBC connection pool (use the built-in) -->
  <property name="connection.pool_size">1</property>
 
  <!-- SQL dialect -->
  <property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>
 
  <!-- Enable Hibernate's automatic session context management -->
  <property name="current_session_context_class">thread</property>
 
  <!-- Disable the second-level cache -->
  <property name="cache.provider_class">org.hibernate.cache.internal.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>
  
  <!-- Names the annotated entity class-->
  <mapping class="org.javabrains.dto.UserDetails"/>
  
  </session-factory>
 </hibernate-configuration>
package org.javabrains.dto;
 
 import javax.persistence.Entity;
 
 @Entity
 public class UserDetails {
  
  private int userId;
  private String userName;
  
  public int getUserId() {
  return userId;
  }
  public void setUserId(int userId) {
  this.userId = userId;
  }
  public String getUserName() {
  return userName;
  }
  public void setUserName(String userName) {
  this.userName = userName;
  }
  
 }
package org.javabrains.hibernate;
 
 import org.hibernate.Session;
 import org.hibernate.SessionFactory;
 import org.hibernate.cfg.Configuration;
 import org.javabrains.dto.UserDetails;
 
 public class HibernateTest {
 
  public static void main(String[] args) {
  UserDetails user = new UserDetails();
  
  user.setUserId(1);
  user.setUserName("Tet");
  
  //Hibernate API to save this objects to DB
  //Session factory is created only ONCE
  SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
  Session session = sessionFactory.openSession();
  
  //create transaction
  session.beginTransaction();
  session.save(user);
  
  //end the transaction
  session.getTransaction().commit();
  
  //Closing the session
  session.close();
  
  
  }
 
 }

This returns:

Mar 31, 2016 3:55:09 PM org.hibernate.Version logVersion
 INFO: HHH000412: Hibernate Core {5.1.0.Final}
 Mar 31, 2016 3:55:09 PM org.hibernate.cfg.Environment <clinit>
 INFO: HHH000206: hibernate.properties not found
 Mar 31, 2016 3:55:09 PM org.hibernate.cfg.Environment buildBytecodeProvider
 INFO: HHH000021: Bytecode provider name : javassist
 Mar 31, 2016 3:55:09 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.
 Mar 31, 2016 3:55:10 PM org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit>
 INFO: HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
 Mar 31, 2016 3:55:10 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
 WARN: HHH10001002: Using Hibernate built-in connection pool (not for production use!)
 Mar 31, 2016 3:55:10 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
 INFO: HHH10001005: using driver [org.postgresql.Driver] at URL [jdbc:postgresql://localhost:5432/hibernatedb]
 Mar 31, 2016 3:55:10 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
 INFO: HHH10001001: Connection properties: {user=sa, password=****}
 Mar 31, 2016 3:55:10 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
 INFO: HHH10001003: Autocommit mode: false
 Mar 31, 2016 3:55:10 PM org.hibernate.engine.jdbc.connections.internal.PooledConnections <init>
 INFO: HHH000115: Hibernate connection pool size: 1 (min=1)
 Exception in thread "main" org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
  at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:244)
  at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:208)
  at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:189)
  at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:51)
  at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:94)
  at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:217)
  at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:189)
  at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.handleTypes(MetadataBuildingProcess.java:352)
  at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:111)
  at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.build(MetadataBuildingProcess.java:83)
  at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:418)
  at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:87)
  at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:692)
  at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:724)
  at org.javabrains.hibernate.HibernateTest.main(HibernateTest.java:18)
 Caused by: org.hibernate.exception.JDBCConnectionException: Error calling Driver#connect
  at org.hibernate.engine.jdbc.connections.internal.BasicConnectionCreator$1$1.convert(BasicConnectionCreator.java:105)
  at org.hibernate.engine.jdbc.connections.internal.BasicConnectionCreator.convertSqlException(BasicConnectionCreator.java:123)
  at org.hibernate.engine.jdbc.connections.internal.DriverConnectionCreator.makeConnection(DriverConnectionCreator.java:41)
  at org.hibernate.engine.jdbc.connections.internal.BasicConnectionCreator.createConnection(BasicConnectionCreator.java:58)
  at org.hibernate.engine.jdbc.connections.internal.PooledConnections.addConnections(PooledConnections.java:106)
  at org.hibernate.engine.jdbc.connections.internal.PooledConnections.<init>(PooledConnections.java:40)
  at org.hibernate.engine.jdbc.connections.internal.PooledConnections.<init>(PooledConnections.java:19)
  at org.hibernate.engine.jdbc.connections.internal.PooledConnections$Builder.build(PooledConnections.java:138)
  at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl.buildPool(DriverManagerConnectionProviderImpl.java:110)
  at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl.configure(DriverManagerConnectionProviderImpl.java:74)
  at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:94)
  at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:217)
  at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:189)
  at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.buildJdbcConnectionAccess(JdbcEnvironmentInitiator.java:145)
  at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:66)
  at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35)
  at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:88)
  at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:234)
  ... 14 more
 Caused by: org.postgresql.util.PSQLException: FATAL: password authentication failed for user "sa"
  at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:433)
  at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:208)
  at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:66)
  at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:215)
  at org.postgresql.Driver.makeConnection(Driver.java:406)
  at org.postgresql.Driver.connect(Driver.java:274)
  at org.hibernate.engine.jdbc.connections.internal.DriverConnectionCreator.makeConnection(DriverConnectionCreator.java:38)
  ... 29 more

I don’t have any experience with the “unable to create requested service [org.hibernate.engine.jdbc.env.spi.jdbcenvironment].” In this case, how should I change?

hibernate
  • 2 2 Answers
  • 1k Views
  • 0 Followers
  • 0
Answer
Share
  • Facebook
  • Report

2 Answers

  • Voted
  • Oldest
  • Recent
  • Random
  1. Best Answer
    hdtutoria Expert
    2022-06-12T12:06:58+00:00Added an answer on June 12, 2022 at 12:06 pm

    The cause: This error occurs because hibernate was unable to connect to the database.

    The solution:

    1. Make sure you have a database on the server that is mentioned in the configuration file, such as “hibernatedb” in this example.
    2. Check that the username and password used to connect to the database are correct.
    3. Verify that the necessary jars for the connection are mapped to the project.
    • 12
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report
  2. Adam Grand
    2022-05-25T20:43:27+00:00Added an answer on May 25, 2022 at 8:43 pm

    Reason: Hibernate was unable to connect to the database. Solution:

    1. Make sure you have a database on the server that is referred to by the configuration file, eg. In this instance, “hibernatedb”.

    2. Verify that the username and password used to connect to the DB are correct.

    3. Make sure that the relevant jars for the connection are mapped into the project.

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

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

Sidebar

Ask A Question
  • How to Split String by space in C++
  • How To Convert A Pandas DataFrame Column To A List
  • How to Replace Multiple Characters in A String in Python?
  • How To Remove Special Characters From String Python

Explore

  • Home
  • Tutorial

Footer

ITtutoria

ITtutoria

This website is user friendly and will facilitate transferring knowledge. It would be useful for a self-initiated learning process.

@ ITTutoria Co Ltd.

Tutorial

  • Home
  • Python
  • Science
  • Java
  • JavaScript
  • Reactjs
  • Nodejs
  • Tools
  • QA

Legal Stuff

  • About Us
  • Terms of Use
  • Privacy Policy
  • Contact Us

DMCA.com Protection Status

Help

  • Knowledge Base
  • Support

Follow

© 2022 Ittutoria. All Rights Reserved.

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.