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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:50:22+00:00 2026-06-15T14:50:22+00:00

I tried to test if SessionFactory was valid through: assertFalse(sessionFactory.isClosed()); But my test passes

  • 0

I tried to test if SessionFactory was valid through:

assertFalse(sessionFactory.isClosed());

But my test passes even if the underlaying datasource could not get connections:

java.sql.SQLException: Connections could not be acquired from the underlying database!

How can I test if the SessionFactory is valid?

  • 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-06-15T14:50:23+00:00Added an answer on June 15, 2026 at 2:50 pm

    Seems like you really want to test whether you have valid database connectivity. SessionFactory is just a wrapper, once configured it will work as long as underlying DataSource is fine.

    So how do you test DataSource? First of all various connection pools allow you to define so-called test query. Typically "SELECT 1". If your database connection pool does not expose such a functionality, just pick any connection from your pool and run similar query.

    See also

    • How does Spring-JPA EntityManager handle "broken" connections?
    • How to get jdbc connection from hibernate session?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I tried - Test\d\d\d and it works but problem is, String in expression could
I tried to make http get request with code: String username = test\\v100; String
I tried to test this myself before asking on the forum but my simple
I tried a test file which is working but this file isn't. I also
So how big can a $variable in PHP get? I've tried to test this,
Tried to test Dialog with Spinner and got: NullPointerException: can't get shadow for null
I downloaded the jira4r-jh gem and tried to test it from irb, but as
My Rails app passes its test but then says 0% passed. Its a Rails
I tried to test an example of C++11 threads in Eclipse. But I got
I tried to test Haskell performance, but got some unxepectedly poor results: -- main

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.