I want to connect to MySQL DB by using script runner. I applied behavior for this on a custom field. I paste the driver jar file in <jira-install>\lib and also studied this scriptrunner tutorial https://scriptrunner.adaptavist.com/latest/jira/recipes/misc/connecting-to-databases.html . But I still getting this error. Am I doing it in right way?
script:-
def driver = Class.forName("com.mysql.cj.jdbc.Driver").newInstance() as Driver
def prop= new Properties()
prop.setProperty("user","admin")
prop.setProperty("password","123456780")
def conn=driver.connect("jdbc:mysql://localhost:3306/ISE_DB",prop)
def sql=new Sql(conn)
try {
sql.eachRow("select count(*) from Customer_View") {
log.debug(it)
}
} finally {
sql.close()
conn.close()
}
2018-02-01 12:17:45,242 http-nio-8080-exec-11 ERROR admin 737x410x2 73padh 0:0:0:0:0:0:0:1 /rest/scriptrunner/behaviours/latest/runvalidator.json [c.o.jira.behaviours.BehaviourManagerImpl] Script function failed on issue: (create issue) project/issuetype: IFT/Task, user: admin, fieldId: customfield_10202, file: <inline script>
java.lang.ClassNotFoundException: com.mysql.cj.jdbc.Driver not found by com.onresolve.jira.groovy.groovyrunner [173]
at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1532)
at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:75)
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1955)
at Script1.run(Script1.groovy:7)