Groovy sql errors on remote Mysql server?
I'm using groovy gsql to query to Mysql database. Everything goes well on localhost (testing mode), unfortunately when I switching to remote db groovy don't query db.
Here is the code :
def sqlModule = Sql.newInstance("jdbc:mysql://localhost/module-test", "b", "b", "com.mysql.jdbc.Driver")
def sampleQuery(int dataset) {
def SampleQueryList = []
// Sql query
sqlModule.eachRow("""
select b.*
from dataset_group_set_details a, array_data b
where dataset_id = "${dataset}"
and group_set_id = 1
and a.array_data_id = b.array_data_id ;""")
{
def addSample= new Sample(it.toRowResult())
addSample.id = "${it.array_data_id}" as int
addSample.dateCreatedSample = dateFormat.parse("${it.date_created}")
addSample.tissueTypeId = "${it.tissue_type_id}" as int
...
// Add Sample to SampleList
SampleQueryList << addSample
}
return SampleQueryList
In localhost mode, "return SampleQueryList" return a good list, but in remote mode (ex : jdbc:mysql://192.168.209.32/module-t开发者_JS百科est) my list is empty.
Note : Db in localhost and remote are equals. Also, I have no error in remote mode.Why, in localhost mode groovy quering my db and not in remote mode ?
Any ideas ?With out more information it's impossible to say what's wrong for sure. Have you tried a simple
select * from tablename
query to make sure your getting a connection to the database? It's possible your trying to connect with the wrong user name and password. If you don't control the database restrictions may be in place limiting the length and complexity of queries you can execute on the remote server with the given user account.
精彩评论