Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Connecting to External MS SQL Database from JIRA using Groovy SQL

 
Nishant Kansal
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I am trying to "connect to an external Microsoft SQL server using groovy sql from within JIRA using script runner console". For the security purpose, I have not mentioned the real values.
Set-up: The SQL JDBC connector has been added as a CLASSPATH in System Variable, location "C:\TEMP\sqljdbc4" downloaded from "sqljdbc_4.0.2206.100_enu". With the actual values, I am able to successfully connect to the SQL Server via SQL Manager Studio.
Problem: The below script is returning "null".
----------------------------
import groovy.sql.Sql
import java.sql.Driver
try{
def driver = Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance() as Driver

def props = new Properties()
props.setProperty("user", "Valid User Name")
props.setProperty("password", "Valid Password")
props.setProperty("database", "Valid DB")
def conn = driver.connect("jdbc:sqlserver://Valid_Server_Name:Valid DB", props)
def sql = new Sql(conn)
log.info "Connected to database successfully"
}
catch(Exception e){
log.info "some db error"
log.info e.getMessage()
}
----------------------------
Please help.
Thanks,
Nishant
 
Tim Holloway
Saloon Keeper
Posts: 18359
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It took me several scans of your message to make sense of that.

You're talking like Jira is a build system. Unless it has changed really radically in the last 6 months, it's a ticketing system. I think maybe the Atlassian product you're asking about is Bamboo.

You'd do better if you did a full stack trace print and showed us what that looked like.

One thing, however, Atlassian products are built off standard Java resources, and in the case of online systems that usually includes either an embedded Tomcat server or the option of deploying the app in a Tomcat server you already have. If that's what's running your faiing code then supplying resources from an external CLASSPATH (as a system or environment variable) won't work. Tomcat builds its own classpaths. Usually for JDBC drivers, you drop the driver in the TOMCAT_HOME/lib directory. If this is a build script, however, it may contain a run profile and you might need to add your jar path there.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic