on 01-24-2014 04:31 PM
Rusheel Jain:Hello,
We were working with groovy script in social miner and were trying to access a database for tagging. For this we were importing "groovy.sql.Sql". The script works fine when tested with Eclipse. But after deploying the script in SocialMiner we got an exception -
java.lang.SecurityException: Importing [groovy.sql.Sql] is not allowed.
So is importing this file not allowed ? Any alternatives regarding the same would be helpful.
Thanks !
Rusheel Jain:
Hi,
As Tetyana had mentioned you, In groovy script you can use the rest object to either invoke an external webservice or a web application where to do whatever you want.
Here is what we do to invoke an URL passing parameters. I hope this would help you.
Regards.
import groovyx.net.http.HttpResponseDecorator
HttpResponseDecorator resp = restClient.get(
uri: "http://172.17.56.130:8090/web_get_groovy/Process",
query : [
title : socialContact.getProperties().get("title") != null ? socialContact.getProperties().get("title").toString() : "null",
link : socialContact.getProperties().get("link") != null ? socialContact.getProperties().get("link").toString() : "null",
author : socialContact.getProperties().get("author") != null ? socialContact.getProperties().get("author").toString() : "null",
publishedDate : socialContact.getProperties().get("publishedDate") != null ? socialContact.getProperties().get("publishedDate").toString() : "null",
categories : socialContact.getProperties().get("categories") != null ? socialContact.getProperties().get("categories").toString() : "null",
tags : socialContact.getProperties().get("tags") != null ? socialContact.getProperties().get("tags").toString() : "null",
description : socialContact.getProperties().get("description") != null ? socialContact.getProperties().get("description").toString() : "null",
sourceLink : socialContact.getProperties().get("sourceLink") != null ? socialContact.getProperties().get("sourceLink").toString() : "null",
ID_PUBLICACION: "2.1"
]);
if (resp.isSuccess()) {
log "ResponseFromPSO:" + resp.dump()
} else {
log "NO_ResponseFromPSO" + resp.dump()
}
Hi,
Thanks for your reply! Our script right now is just fetching some data from sql server 2008. The code is like this-
import groovy.sql.Sql
sql = Sql.newInstance(
"jdbc:sqlserver://192.168.1.xx;databaseName=abcd;user=username;password=pass",
“username",
“password"
"com.microsoft.sqlserver.jdbc.SQLServerDriver"
)
sql.eachRow('Select * from tablename')
{
var = it.fieldname
i = i+1
}
I went through the SocialMiner API, which says that certain SQL commands were not allowed. So are such queries allowed ?
because it seems a very basic SQL query where i am fetching data from some table and nothing else.
Thanks
Rusheel Jain:
Hi,
Thanks for your reply! Our script right now is just fetching some data from sql server 2008. The code is like this-
import groovy.sql.Sql
sql = Sql.newInstance(
"jdbc:sqlserver://192.168.1.xx;databaseName=abcd;user=username;password=pass",
“username",
“password"
"com.microsoft.sqlserver.jdbc.SQLServerDriver"
)
sql.eachRow('Select * from tablename')
{
var = it.fieldname
i = i+1
}
I went through the SocialMiner API, which says that certain SQL commands were not allowed. So are such queries allowed ?
because it seems a very basic SQL query where i am fetching data from some table and nothing else.
Thanks
Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: