Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Groovy Script Error Message

Sinan Yesilyurt
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 21, 2014

Hi,

I'm getting groovy records from SQL Table or Function. Example;

 

String subeKodu = get_sube_kodu_bul(matcher[0][1])
private String get_sube_kodu_bul(String subeAdi)
{
	def sql = Sql.newInstance("jdbc:jtds:sqlserver://10.xx.xx.xx:1433/DBNAME", "usrname","pass", "net.sourceforge.jtds.jdbc.Driver")
	subeAdi = subeAdi.trim()
	def row = sql.firstRow("SELECT TOP 1 SUBE_KODU FROM TABLENAME WHERE SUBE_ADI= '${subeAdi}'")
	if (row != null)
		return (String)row.SUBE_KODU
	else
		return ""
}
But  I am faced with the following error;
WARNING: In Groovy SQL please do not use quotes around dynamic expressions (which start with $) as this means we cannot use a JDBC PreparedStatement and so is a security hole. Groovy has worked around your mistake but the security hole is still there. The expression so far is: SELECT TOP 1 YETKILI FROM TABLENAME WHERE SUBE_ADI = '?'
Help please, thank you

2 answers

1 accepted

0 votes
Answer accepted
Sinan Yesilyurt
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 30, 2015

Connection change and solved.

0 votes
Alexey_Rjeutski__Polontech_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 21, 2014

Try the following:

def row = sql.firstRow("SELECT TOP 1 SUBE_KODU FROM TABLENAME WHERE SUBE_ADI= ?",[subeAdi])

Sinan Yesilyurt
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 21, 2014

Hi Alexey, the same error

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, mindful member, mindful member badge, atlassian community, community kudos, community giveaway, atlassian swag, community values, empathy and kindness, badge challenge, atlassian learning, community engagement, swag giveaway

Earn a Badge, Win a Prize 🎁

Earning the Mindful Member badge proves you know how to lead with kindness, plus it enters you into a giveaway for exclusive Atlassian swag. Take the quiz, grab the badge, and comment on our announcement article to spread the good vibes!

Start here
AUG Leaders

Atlassian Community Events