I am trying to connect a simple groovy script to the DB.
Code:
import groovy.sql.Sql
class GroovySqlExample2{
static void main(String[] args) {
def sql = Sql.newInstance("jdbc:sqlserver://MYSERVERIP", "uname",
"pwd", "net.sourceforge.jtds.jdbc.Driver")
sql.eachRow("select * from word"){
println it.spelling +...
I have this code in a Grails 1.0.4 Groovy console:
def devices = Device.getAll()
def found = devices.findAll {
if(it?.localNumber && it?.areaCode){
def pattern = ~".*${it.areaCode + it.localNumber}"
def matches = "$msisdn" ==~ pattern
println "$matches == msisdn: $msisdn ==~ pattern: $pattern"
matche...
I am trying to get the first word in the line that matches the whole word 'number'. But I am only interested where whole word 'number' is matched and is preceded by a tab.
For example if following is the text:
tin identification number 4/10/2007 LB
num number 9/27/2006 PAT
I want to get back num
Regex I have is:
match whole word...
I'm planning to broaden my perspectives in JVM platform, and I've got a dilemma: what should I learn first? Could you please explain, what are the advantages of Groovy, Scala and other languages for JVM? Thanks.
...
I have placed the ojdbc14.jar in the lib folder and am using the code below to connect to oracle:
import java.sql.Connection
import java.sql.DriverManager
import javax.sql.DataSource
import groovy.sql.Sql
import oracle.jdbc.driver.OracleTypes
driver = oracle.jdbc.driver.OracleDriver
Connection conn = DriverManager.getConnection(
'...
Hi!
I am developing an application which should work under different languages (german, spanish, etc). The application uses an Oracle DB.
I have CRUD business processes and I have the standard views (create, edit, show, list).
No problems for creating, showing and listing any record containing special chars
like ä,ö,ü, etc.
But when I e...
Hi,
If I have a simple Groovy class such as
class Address {
Integer streetNumber
String streetName
String state
String zip
Country country
}
Although I could write (or use an IDE to generate) hashCode and equals methods like:
boolean equals(o) {
if (this.is(o)) return true;
if (!o || getClass() != o.class) re...
Hi,
I'm using ehcache (via the Grails plugin). The method that adds objects to the cache requires the keys to be serializable, so a typical usage would be:
def key = 22
def someObject = new Object();
cacheService.cache(key, true, someObject)
(The boolean param indicates whether the object should be added to a distributed or local cac...
I've been using the newest version of the groovy eclipse plugin (for eclipse 3.4) and I noticed that when I run organize imports on the file, it actually removes some of the imports that I need. It seems to remove the ones in my project, not java.* imports. Any ideas why?
thanks,
Jeff
...
I have a class in src/groovy in my grails project.
How do i make a log field that gets injected with the correct logger for that class ?
Is there a commons logging or just log4j in grails ?
...
I am looking for how the methods like ArrayList#sort(Closure) are implemented in Groovy. I've downloaded Groovy's source in a zip (http://groovy.codehaus.org/Building+Groovy+from+Source), but I can't find any file containing the source of extension methods to ArrayList. Does anyone know where these Groovy extensions for Java's collecti...
Groovys' NodeBuilder uses
def someBuilder = new NodeBuilder()
someBuilder.people(kind:'folks', groovy:true) {
person(x:123, name:'James', cheese:'edam') {
project(name:'groovy')
project(name:'geronimo')
}
person(x:234, name:'bob', cheese:'cheddar') {
project(name:'groovy')
project(name:'drools')
}
}
whereas ...
Hi,
I am having problems defining one-to-one and one-to-many relationships with domain classes.
I have the following domain classes
class Team {
static hasMany = [players: Player]
static hasOne = [coach: Coach]
}
class Person {
String name
}
class Player extends Person {
}
class Coach extends Person {
}
So my question...
I am Serializing an object which has a deep hierarchy of objects.
After deserialization, i am able to access only those fields which were available in object before serialization. For rest, i get LazyInitializationException.
class A {
List<B> objs
}
class B {
C c
}
class C {
D d
}
Initially, i used to get LazyInitiali...
I am new to Java. Its only been six months but I do understand Java.
While reading about it sometimes, I come across these terms - Groovy, Grails, Hibernate, JBoss, Jade and many more.
I know I can read all about them individually. But can somebody give me a treetop view of what is happening here?
What is all this? We have Java and th...
I have a controller that needs to return a 404 page and status code on certain conditions. I can't seem to find out how to do this in Grails. A coworker recommended this method:
response.sendError(HttpServletResponse.SC_NOT_FOUND)
which works perfectly fine, but it's not very Grails-like. I know Rails' render method take a status argu...
We have an admin debug console in our app that lets you enter a script
and submit it to get the result back. We're not worried about
malicious users, but would like to prevent basic stuff like someone
entering System.exit(1) just to see what it does. Unfortunately,
adding a security policy file isn't an option. Is there any other way
to...
Hi
I am developing an application -called smtool- using Groovy and Grails.
This application must be integrated to a portal.
The portal have the restriction that every link must be relative.
No absolute paths are allowed neither for links nor for images, js files,
css files, etc.
My application has a menu with many links pointing to di...
I am looking into the groovy-wicket integration and lack of anonymous inner classes seems to be a problem when writing the event handlers.
Is there a groovier way of writing this code
import org.apache.wicket.PageParameters
import org.apache.wicket.markup.html.basic.Label
import org.apache.wicket.markup.html.link.Link
import org.apache....
Please pardon this newbie question...
In Grails, if I want a partial to be embedded in a layout so that it appears globally, which requires live data, let's say a list of categories, where is the best place to pull the category data to feed it into the view?
I realize this is a very basic question, but I haven't seen this covered in a...