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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:11:59+00:00 2026-06-07T08:11:59+00:00

What are some lightweight options for persistence in Groovy? I’ve considered serialization and XML

  • 0

What are some lightweight options for persistence in Groovy? I’ve considered serialization and XML so far but I want something a bit more robust than those, at least so I don’t have to rewrite the entire file every time. Ideally, it would:

  • Require no JARs in classpath, using Grapes instead
  • Require no external processes, administration, or authentication (so all embedded)
  • Support locking

I plan on using it to cache some information between runs of a standalone Groovy script. I imagine responses will focus around SQL and NoSQL databases. Links to pages demonstrating this usage would be appreciated. Thanks!

  • 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-07T08:12:01+00:00Added an answer on June 7, 2026 at 8:12 am

    Full SQL Database

    The h2 in-process SQL database is very easy to use. This is the same database engine grails uses by default, but it’s simple to use in a groovy script as well:

    @GrabConfig(systemClassLoader=true)
    @Grab(group='com.h2database', module='h2', version='1.3.167')
    
    import groovy.sql.Sql
    
    def sql = Sql.newInstance("jdbc:h2:hello", "sa", "sa", "org.h2.Driver")
    sql.execute("create table test (id int, value text)")
    sql.execute("insert into test values(:id, :value)", [id: 1, value: 'hello'])
    println sql.rows("select * from test")
    

    In this case the database will be saved to a file called hello.h2.db.

    Simple Persistent Maps

    Another alternative is jdbm, which provides disk-backed persistent maps. Internally, it uses Java’s serialization. The programming interface is much simpler, but it’s also much less powerful than a full-blown SQL db. There’s no support for concurrent access, but it is synchronized and thread safe, which may be enough depending on your locking requirements. Here’s a simple example:

    @Grab(group='org.fusesource.jdbm', module='jdbm', version='2.0.1')
    
    import jdbm.*
    
    def recMan = RecordManagerFactory.createRecordManager('hello')
    def treeMap = recMan.treeMap("test")
    treeMap[1] = 'hello'
    treeMap[100] = 'goodbye'
    recMan.commit()
    println treeMap
    

    This will save the map to a set of files.

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

Sidebar

Related Questions

Suppose I want to render/present a text transmitted in the form of some lightweight
I need to add some lightweight syntactic sugar to JavaScript source code, and process
I am getting the following error from some users while performing a lightweight Core
Could you recommend some lightweight jQuery plugin to detect if fields specified by selector
I'd like to utilize some lightweight task management (e.g. ScheduledThreadPoolExecutor) for periodically doing some
Something similar has been asked in maven user list but I have the situation,
I am trying out some cascade options with nhibernate mapping and have a unit
Back in the old days, Help was not trivial but possible: generate some funky
I'm writing an application in groovy with grails that needs to do some automated
I've had this idea of a music project that I want to do. But

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.