Hi again John,
I've set up a local MySQL database and modified your function to be as follows:
package john.overbaugh.utils
import groovy.sql.Sql
public class DBUtils
{
def static CountEntriesInTable(entryColumnName, entryValue, tableName, log, stopOnError)
{
def myCount
def db = Sql.newInstance('jdbc:mysql://127.0.0.1/db_ole', 'root', 'XXX', 'com.mysql.jdbc.Driver')
def myQuery = "SELECT count($entryColumnName) from $tableName WHERE $entryColumnName = '$entryValue'"
log.info("Counting the instances of $entryValue in column $entryColumnName in table $tableName")
log.info(myQuery)
try
{
myCount = db.firstRow(myQuery)[0]
}
catch (Exception e)
{
e.printStackTrace()
}
finally
{
log.info(" - Count = " + myCount)
return myCount
} }
}
Then I call this with
import john.overbaugh.utils.DBUtils
log.info( DBUtils.CountEntriesInTable( 'name', 'ole', 'db_ole.tb_test', log, false ))
and get the correct result back.. could you see how this differs from your setup? maybe it works for you as well?
regards!
/Ole
eviware.com