I want to get values from SQL Server by Groovy.
Sql.withInstance("jdbc:jtds:sqlserver://localhost;instance=SQLEXPRESS;",
'login',
'password',
'net.sourceforge.jtds.jdbcx.JtdsDataSource') {
it.execute("use Base")
it.rows("select * from table") {
List val = it.values()
}
...
}
Method rows() should return List<GroovyRowResult>, but I have:
groovy.lang.MissingMethodException: No signature of method: net.sourceforge.jtds.jdbc.JtdsResultSetMetaData.get() is applicable for argument types: () values: []
What am I doing wrong and how can I get values from database?
Because when you use List val = it.values() , the "it" is mean JtdsResultSetMetaData . that is not your expect ResultSet and JtdsResultSetMetaData do not have values() method so will get exception. you can use this code try get your ResultSet
Sql.withInstance("jdbc:jtds:sqlserver://localhost;instance=SQLEXPRESS;",
'login',
'password',
'net.sourceforge.jtds.jdbcx.JtdsDataSource') {
it.execute("use Base")
List val = it.rows("SELECT * FROM table")
print val
...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With