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 336319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:13:53+00:00 2026-05-12T10:13:53+00:00

I have hibernate.cfg.xml file. <session-factory> <!– Database connection settings –> <property name=connection.driver_class>com.mysql.jdbc.Driver</property> <property name=connection.url></property>

  • 0

I have hibernate.cfg.xml file.

<session-factory>

    <!-- Database connection settings -->
    <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
    <property name="connection.url"></property>
    <property name="connection.username"></property>
    <property name="connection.password"></property> 

    <!-- JDBC connection pool (use the built-in) -->
    <property name="connection.pool_size">1</property>

…………………

This is the most interesting part of file.
Now i must set missing values: url, username, password.
I’m trying to do in such way:

public static void SetSessionFactory() {
    try {

      AnnotationConfiguration conf = new AnnotationConfiguration().configure();
      // <!-- Database connection settings -->
      conf.setProperty("connection.url", URL);
      conf.setProperty("connection.username", USERNAME);
      conf.setProperty("connection.password", PASSWORD);
      SESSION_FACTORY = conf.buildSessionFactory();

    } catch (Throwable ex) {
      // Log exception!
      throw new ExceptionInInitializerError(ex);
    }
  }

But it just loads my configuration from hibernate.cfg.xm and do not changing any property…

url, username, passoword – are command-line arguments so i must set them on runtime.

  • 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-12T10:13:53+00:00Added an answer on May 12, 2026 at 10:13 am

    Try to call conf.configure(); here.
    And properties may need to have hibernate prefix like “hibernate.connection.username”
    Hope it helps.

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

Sidebar

Related Questions

I have my hibernate.cfg.xml file as, <hibernate-configuration> <session-factory> <property name=hibernate.bytecode.use_reflection_optimizer>false</property> <property name=hibernate.connection.driver_class>com.mysql.jdbc.Driver</property> <property name=hibernate.connection.password>123789</property>
I have following configuration file - <hibernate-configuration> <session-factory name=HibernateSessionFactory> <property name=hibernate.connection.driver_class>com.mysql.jdbc.Driver</property> <property name=hibernate.connection.password>mysql</property> <property
I have my hibernate.cfg.xml There is field: <property name=hibernate.connection.username>username</property> // getUser()??? I have class
I have JRE 1.6 and am using the following hibernate.cfg.xml file. I am always
I have my hibernate.cfg.xml congif file placed in PersistenceManager project as you see in
I do not want to have the hibernate.cfg.xml file. Rather I want to do
I have a hibernate.cfg.xml file, but I'd like to reference it as a dataSource
I have a Java program using a basic Hibernate session factory. I had an
In SpringMVC in src/main/resources I have my hibernate.cfg.xml I have a class that's my
I have the following mapping file: <?xml version=1.0 encoding=utf-8 ?> <hibernate-mapping xmlns=urn:nhibernate-mapping-2.2 assembly=Project1.Accounts namespace=Project1.Core.Domain>

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.