Forums

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

error: com.microsoft.sqlserver.jdbc.SQLServerException: Invalid object name 'itrac_rnd', Scriptrunne

Mouna Hammoudi
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.
October 25, 2023
0

I am using the following code to query my database in scriptrunner for Jira. I am receiving the following error enter image description here

How can I print which object names are available? That way, I know what query to use. package SuperFeature

import com.atlassian.jira.issue.Issue
import org.apache.log4j.Logger
import com.atlassian.jira.project.version.Version
import com.atlassian.jira.bc.project.component.ProjectComponent
import com.atlassian.jira.bc.project.component.ProjectComponentManager
import com.atlassian.jira.security.JiraAuthenticationContext
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.label.LabelManager
import SuperFeature.Configuration_SuperFeature
import groovy.sql.Sql
import java.sql.Driver
import java.sql.*

def log = Logger.getLogger('atlassian-jira.log')
def driver = Class.forName('com.microsoft.sqlserver.jdbc.SQLServerDriver').newInstance() as Driver // <1>
 
def props = new Properties()
props.setProperty("user", "webM_Feature") // <2>
props.setProperty("password", "webM_Feature")
String connectstmt= "jdbc:sqlserver://ireport:1433;RND_webM_Feature="
log.warn("MOUNA CAMELIA "+connectstmt)


 def conn = driver.connect(connectstmt, props) // <3>
 def sql = new Sql(conn)


 
try {

    
    String query = "SELECT cycle, line, prod, fcomp, sfcomp, pm, rnd FROM dbo.itrac_rnd"
    ResultSet rs = sql.executeQuery(query);
        while (rs.next()) {

                log.warn("MOUNA CAMELIA "+rs.getString("cycle"))
                
            }
} finally {
    sql.close()
    conn.close()
}

1 answer

0 votes
Ram Kumar Aravindakshan _Adaptavist_
Community Champion
October 25, 2023 edited

Hi @Mouna Hammoudi

You are getting the error message because there is an error in the Database schema you are currently using.

Please read this Jira KB Document for steps to overcome this issue.

Thank you and Kind regards,

Ram

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, likes for trees, atlassian community, social impact, tree planting campaign, community kudos, atlassian giving, environmental impact, sustainability, likes for good, atlassian social responsibility, community challenge

Make every click count—help us plant 50,000 trees! 🌳

Want to make your everyday Community actions directly contribute to reforestation? The Atlassian Community can achieve this goal by liking a post, attending an ACE, sending your peers kudos, and so much more!

Help us plant more trees
AUG Leaders

Atlassian Community Events