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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:14:43+00:00 2026-05-27T21:14:43+00:00

in common, hibernate sessionfactory is created in spring configuration file (eg spring-dao.xml) like; <bean

  • 0

in common, hibernate sessionfactory is created in spring configuration file (eg spring-dao.xml) like;

<bean id="mySessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation">
<value>file:src/hibernate.cfg.xml</value>
</property>
</bean>

and then in dao,

<bean id="myProductDao" class="product.ProductDaoImpl">
<property name="sessionFactory" ref="mySessionFactory"/>
</bean>

in web.xml, we put the config file (spring-dao.xml) in contextConfigLocation;

<context-param>  
        <param-name>contextConfigLocation</param-name>  
        <param-value>/WEB-INF/spring-dao.xml</param-value>  
</context-param>

when the application is started, datasource is injected to all dao beans.

This was the summary, what my problem is, I do not want spring to connect to database on application startup. I have an admin(responsible for opening db connection after startup) and an admin applet working on remote machine, which communicates with web app servlet. database connection for web application should be opened if authentication is ok.

how can i achieve this goal?

  • 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-27T21:14:44+00:00Added an answer on May 27, 2026 at 9:14 pm

    The solution was not to hard; Create a datasource with no parameters initially, and then setting values after admin credentials ok.

    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
      <!-- Connection properties. All should be ommitted. -->
    </bean>
    
    
    // code below is called after admin login
        DataSource dS = context.getBean("dataSource");
        dS.setUrl("...");
        dS.setUserPass(adminPass);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using spring and hibernate for configuration with mysql db. My we.xml file
I have Hibernate Transaction manager configured inside Spring MVC controller. <bean id=dataSource class=org.apache.commons.dbcp.BasicDataSource destroy-method=close>
I get an error: Caused by: java.lang.ClassNotFoundException: org.hibernate.annotations.common.reflection.ReflectionManager i'n pom.xml i have: <dependency> <groupId>org.hibernate</groupId>
Do you have a common base class for Hibernate entities, i.e. a MappedSuperclass with
Where are the most common places where you've gotten an org.hibernate.LazyInitializationException in Grails, what
A little background: I'm using Spring and Hibernate to create a really simple domain/dao/service
<?xml version=1.0 encoding=UTF-8?> <beans xmlns=http://www.springframework.org/schema/beans xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xmlns:p=http://www.springframework.org/schema/p xsi:schemaLocation=http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd> <bean id=viewResolver class=org.springframework.web.servlet.view.InternalResourceViewResolver p:prefix=/WEB-INF/jsp/ p:suffix=.jsp
I have a SpringMVC+Hibernate web application with the following files: applicationContext.xml <bean id=dataSource destroy-method=close
My goal is to rewrite the sessionFactory section of my xml file into the
Common question but I could use an english explanation. Is it like Java where

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.