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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:41:46+00:00 2026-06-12T20:41:46+00:00

Following the recommended transaction setup for Squeryl , in my Boot.scala: import net.liftweb.squerylrecord.SquerylRecord import

  • 0

Following the recommended transaction setup for Squeryl, in my Boot.scala:

import net.liftweb.squerylrecord.SquerylRecord
import org.squeryl.Session
import org.squeryl.adapters.H2Adapter

SquerylRecord.initWithSquerylSession(Session.create(
  DriverManager.getConnection("jdbc:h2:lift_proto.db;DB_CLOSE_DELAY=-1", "sa", ""),
  new H2Adapter
))

The first startup works fine. I can connect via H2’s web-interface and if I use my app, it updates the database appropriately. However if I restart jetty without restarting the JVM, I get:

java.sql.SQLException: No suitable driver found for jdbc:h2:lift_proto.db;DB_CLOSE_DELAY=-1

The same result is had if I replace “DB_CLOSE_DELAY=-1” with “AUTO_SERVER=TRUE”, or remove it entirely.

Following the recommendations on the Squeryl list, I tried C3P0:

import com.mchange.v2.c3p0.ComboPooledDataSource

val cpds = new ComboPooledDataSource 
cpds.setDriverClass("org.h2.Driver") 
cpds.setJdbcUrl("jdbc:h2:lift_proto") 
cpds.setUser("sa") 
cpds.setPassword("")
org.squeryl.SessionFactory.concreteFactory =
  Some(() => Session.create( 
    cpds.getConnection, new H2Adapter())
  )

This produces similar behavior:

WARNING: A C3P0Registry mbean is already registered. This probably means that an application using c3p0 was undeployed, but not all PooledDataSources were closed prior to undeployment. This may lead to resource leaks over time. Please take care to close all PooledDataSources.

To be sure it wasn’t anything I was doing which was causing this, I started and stopped the server without calling a transaction { } block. No exceptions were thrown. I then added to my Boot.scala:

transaction { /* Do nothing */ }

And the exception was once again thrown (I’m assuming because connections are lazy). So I moved the db initialization code to its own file away from Lift:

SessionFactory.concreteFactory = Some(()=>
  Session.create(
  java.sql.DriverManager.getConnection("jdbc:h2:mem:test", "sa", ""),
  new H2Adapter
))
transaction {}

Results were unchanged. What am I doing wrong? I cannot find any mention of needing to explicitly close connections or sessions in the Squeryl documentation, and this is my first time using JDBC.

I found mention of the same issue here on the Lift google group, but no resolution.

Thanks for any help.

  • 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-12T20:41:47+00:00Added an answer on June 12, 2026 at 8:41 pm

    When you say you are restarting Jetty, I think what you’re actually doing is reloading your webapp within Jetty. Neither the h2 database or C3P0 will automatically shut down when your app reloads, which explains the errors you are receiving when Lift tries to initialize them a second time. You don’t see the error when you don’t create a transaction block because both h2 and C3P0 are initialized when the first DB connection is retrieved.

    I tend to use BoneCP as a connection pool myself. You can configure the minimum number of pooled connections to be > 1, which will stop h2 from shutting down without the need for DB_CLOSE_DELAY=-1. Then you can use:

        LiftRules.unloadHooks append { () =>
          yourPool.close() //should destroy the pool and it's associated threads
        }
    

    That will close all of the connections when Lift is shutdown, which should properly shutdown the h2 database as well.

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

Sidebar

Related Questions

The following script was recommended to use a List Page to show a Google
Following the recommended instructions for resetting root at link and the other recommendations here
I have a MySQL tag-mapping table with structure from the following post - Recommended
When working with an entity, which of the following is recommended? (The following code
To print a number of type off_t it was recommended to use the following
As recommended by http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/mvc.html#mvc-static-resources I wish to use <mvc:resources> for serving my spring static
What is the recommended way of handling the following type of situations: Supposing I
I have the following code, this code was recommended to me by stackoverflow user
I run the following in Apache. Our IT guy recommended Nginx over Apache to
The following example from A Tour of Scala shows how implicit can be used

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.