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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:59:34+00:00 2026-06-02T07:59:34+00:00

I am loading a class and doing some sql select statements, it seems that

  • 0

I am loading a class and doing some sql select statements, it seems that import groovy.sql.Sql needs to be imported. How can I load some library while loading a class?

My code (works fine if I remove Sql operations)

def fClass = new GroovyClassLoader().parseClass( new File( 'plugin/Pi.groovy' ) )
result=fClass.newInstance().buildTags( params, i9piparams, "userRoleCount")

pi.groovy

public class Pi{
    def result

    private def getDbUrl(dbdriver,dbhost,dbport,dbname)
    {
        return "$dbdriver:@$dbhost:$dbport:$dbname"
    }

    public def buildTags(Map<String,String> params,Map<String,String> i9piparams,def i9piType)
    {

        println params
        println i9piparams

        /*some Sql operation*/
        Driver="oracle.jdbc.driver.OracleDriver"
            dbdriver="jdbc:oracle:thin"
        def url=getDbUrl(dbdriver,params.tns,i9piparams.dbport,i9piparams.dbname)           

            def sql = Sql.newInstance(url,params.u,params.x,Driver)

            sql.eachRow("select name, value from v\$parameter where name = 'open_cursors'"){ row ->
                result.name=row.name
                result.value=row.value
            }

    }
}

Output

[pd:admin, u:zx5531d, tns:foner, dh:abds, dn:D35531, dp:11531, un:admin, x:cx15531]
[:, dbname:orcl, dbport:1521, dbtype:oracle]
Exception in thread "main" groovy.lang.GroovyRuntimeException: Could not find matching constructor for: groovy.sql.Sql(org.codehaus.groovy.runtime.GStringImpl, groovy.util.slurpersupport.Attributes, java.lang.String, java.lang.String)
.
.
.
  • 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-02T07:59:35+00:00Added an answer on June 2, 2026 at 7:59 am

    Can you try changing your line:

    def sql = Sql.newInstance(url,params.u,params.x,Driver)
    

    to

    def sql = Sql.newInstance( url, 'zx5531d', params.x, Driver )
    

    What I suspect is that you need to call text() on the attributes when you read them from the XML, so that you get a String rather than a groovy.util.slurpersupport.Attributes class.

    Also, why has Driver got a capital initial letter?

    And (not sure what parameter is), but you probably want to change:

    "select name, value from v\$parameter where name = 'open_cursors'"
    

    to

    "select name, value from v\${Sql.expand(parameter)} where name = 'open_cursors'"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an inner class that downloads some images from the server. The problem
I have some entity types that I would like to lazy load. However, they
I have several buttons that set some variables for another class (via extern). Thing
I have read about dynamically loading your class files when needed in a function
I'm trying to optimize the startup time/class loading time of my Java web app
Please provide a good, thorough tutorial about Java class loading , focusing on how
I am dynamically loading a partial class with dropdownlists. The dropdownlists represent the many
Any re-sources or best-practices for implementing dynamic class re-loading feature into a J2EE WebApp
I am loading an external SWF using the Loader class, and adding it to
After loading a PHP template (using jQuery's load function), this simple script won't make

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.