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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T06:43:04+00:00 2026-05-17T06:43:04+00:00

I have been setting up a scripting envrionment using Groovy. I have a groovy

  • 0

I have been setting up a scripting envrionment using Groovy. I have a groovy script called FrameworkiDatabase.groovy which contains a class of the same name. This works fine. I also have another file called connections.groovy which contains maps like the following:

SUPPORT2=[
 host:"host.name", 
 port:"1521", 
 db:"support2",  
 username:"username", 
 password:"password", 
 dbType:"oracle"
]

This holds a collection of database bookmarks, a bit like an oracle tnsnames file, so I don’t need to remember all the parameters when connecting to databases.

When using groovysh, I can import this using the load command, and it is available in current scope. How can I load it as part of a script the same way? It has no class definition around it – does it need one? I have tried doing that, and adding a static import, but that didn’t work…

I tried something like this, but no luck:

testFrameworkiDatabase.groovy:

import static connections
def db = new FrameworkiDatabase(SUPPORT2)

db.listInvalidObjects()
db.getDBSchemaVersion()
db.getFWiVersion() 
db.getSPVersion()
db.getFileloaderVersion()
db.getAdminToolVersion()
db.getReportsVersion()

So I want to load those connections as constants – is there any way I can do this easily?

  • 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-17T06:43:05+00:00Added an answer on May 17, 2026 at 6:43 am

    Not sure if it’s the best way, but one way would be to write this into Connections.groovy

    class Connections {
      static SUPPORT2 = [
        host:"host.name", 
        port:"1521", 
        db:"support2",  
        username:"username", 
        password:"password", 
        dbType:"oracle"
      ]
    }
    

    Then, compile this with groovyc Connections.groovy to generate a class file

    Then, in your test script or on the groovysh prompt, you can do:

    import static Connections.*
    
    println SUPPORT2
    

    To get the output:

    [host:host.name, port:1521, db:support2, username:username, password:password, dbType:oracle]
    

    If compiling the Connections.groovy class isn’t good enough, I think you’re going to be looking at loading the source into a Binding object by using one of the Groovy embedding techniques

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

Sidebar

Related Questions

I have been struggling with setting up an iOS (Objective-C) app which utilizes the
I have been working on setting up a git server by using Paramiko to
I have been trying to setting up a function, which is getting the time
I have recently been setting up SVN in Eclipse using the Subversive plugin (I
I am using Java EE with Spring framework. I have been setting up a
I have been setting up an IP blocklist reciently and I was wondering is
I've been setting up a project to run with MVC Turbine and have been
I have been hiding a row in a WPF grid by setting the Height
So I am kind of new to setting up servers. And I have been
I have problems setting the focus on an input element that has been created

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.