groovy-console

Unable to connect to oracle database from groovy

为君一笑 提交于 2021-02-10 09:30:07
问题 Hi i am unable to connect to oracle database in groovy . I have used the following code in groovy console but getting the following compilation error unable to resolve class oracle.jdbc.driver.OracleTypes at line: 5, column: 1 I have used the following code import java.sql.Connection import java.sql.DriverManager import javax.sql.DataSource import groovy.sql.Sql import oracle.jdbc.driver.OracleTypes sql = Sql.newInstance("jdbc:oracle:thin:@localhost:1521:databasename", "username", "password",

Unable to connect to oracle database from groovy

£可爱£侵袭症+ 提交于 2021-02-10 09:29:50
问题 Hi i am unable to connect to oracle database in groovy . I have used the following code in groovy console but getting the following compilation error unable to resolve class oracle.jdbc.driver.OracleTypes at line: 5, column: 1 I have used the following code import java.sql.Connection import java.sql.DriverManager import javax.sql.DataSource import groovy.sql.Sql import oracle.jdbc.driver.OracleTypes sql = Sql.newInstance("jdbc:oracle:thin:@localhost:1521:databasename", "username", "password",

How do you configure GroovyConsole so I don't have to import libraries at startup?

人走茶凉 提交于 2020-01-01 03:05:06
问题 I have a groovy script that uses a third party library. Each time I open the application and attempt to run my script I have to import the proper library. I would like to be able to open GroovyConsole and run my application without having to import the library. 回答1: In Linux you also have /usr/share/groovy/conf/groovy-starter.conf Here you can add your specific libs: # load user specific libraries load !{user.home}/.groovy/lib/*.jar load /home/squelsh/src/neo4j-community-1.4.M03/lib/*.jar

GroovyConsole ActiveMQ error: NoClassDefFoundError: Could not initialize class org.apache.activemq.ActiveMQPrefetchPolicy

∥☆過路亽.° 提交于 2019-12-24 03:45:06
问题 I am trying to run a very simple ActiveMQ client script in GroovyConsole. I've included activemq-all-5.5.0.jar and slf4j-api-1.5.11.jar through the Script > Add Jar to ClassPath menu. I see org.apache.activemq.ActiveMQPrefetchPolicy in the activemq jar, yet I am getting the exception below. Here is the script: import org.apache.activemq.* import org.apache.activemq.command.* import javax.jms.* // // // def connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61616") def

Groovy Console read input

孤街醉人 提交于 2019-12-20 09:17:45
问题 I'm just starting to learn Groovy and I am experimenting in GroovyConsole. Is there a way I can read user input? I have tried the code below but I get an error. BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) print "Input:" input = br.readLine() println "You entered: $input" This is the error I am receiving: Exception thrown 17-Apr-2012 02:52:39 org.codehaus.groovy.runtime.StackTraceUtils sanitize WARNING: Sanitizing stacktrace: java.io.IOException: Stream closed Is

error seeing when parsing the json response using groovy

自作多情 提交于 2019-12-11 15:36:52
问题 import groovy.json.JsonSlurper def testStepName = 'Adding_Users' def jsonSlurper = new JsonSlurper() def response = context.expand('$(testStepName#Response)') def usersInfomration = jsonSlurper.parseText(response) String userName = userInformation.name log.info UserName 来源: https://stackoverflow.com/questions/58326431/error-seeing-when-parsing-the-json-response-using-groovy

groovy script Error

拥有回忆 提交于 2019-12-11 07:12:46
问题 I am newbie to groovy. In command prompt (I am not using any IDE), I typed following : (No Problem with environment variables settings please) groovy -n -e "println line.toLong()" data.txt Error : Caught: java.io.IOException: Invalid argument java.io.IOException: Invalid argument data.txt is there in that directory (verified using TAB key) Not sure why its throwing Error ???? [data.txt contains raw data in following format] 1 2 3 4 回答1: I tried to duplicate the problem with Groovy 2.3.6 and

Listing subclasses doesn't work in Ruby script/console?

我与影子孤独终老i 提交于 2019-12-11 06:57:08
问题 This works: >> class Foo >> def xyz() >> Foo.subclasses >> end >> end => nil >> class Bar < Foo >> end => nil >> class Quux < Bar >> end => nil >> Foo.new.xyz() => ["Quux", "Bar"] But this doesn't. User is a class in my application. >> User.subclasses NoMethodError: protected method `subclasses' called for #<Class:0x20b5188> from [...]/vendor/rails/activerecord/lib/active_record/base.rb:1546:in `method_missing' from (irb):13 But this does! >> Foo.subclasses => ["Quux", "Bar"] What's going on

get path to groovy source file at runtime

删除回忆录丶 提交于 2019-12-11 03:07:30
问题 Given the following directory structure: /home/some/random/foler/myScript.grooy ... how can I programmatically obtain the path to myScript.grooy parent directory right in the script itself? Ultimately I'm trying to read in several files from the same directory the script is in. EDIT: trying to run it on Windows 7, Groovy 2.0.1, groovy console 回答1: Well, the solution is in Java's File class: println new File(".").absolutePath If you want to obtain every groovy script in the same directory,

How do you configure GroovyConsole so I don't have to import libraries at startup?

浪子不回头ぞ 提交于 2019-12-03 07:28:00
I have a groovy script that uses a third party library. Each time I open the application and attempt to run my script I have to import the proper library. I would like to be able to open GroovyConsole and run my application without having to import the library. In Linux you also have /usr/share/groovy/conf/groovy-starter.conf Here you can add your specific libs: # load user specific libraries load !{user.home}/.groovy/lib/*.jar load /home/squelsh/src/neo4j-community-1.4.M03/lib/*.jar load /home/squelsh/src/neo4j-community-1.4.M03/system/lib/*.jar Hope it helps, had to search long time to find