Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error while getting values from DB

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?

like image 749
AlexandrM Avatar asked Mar 16 '26 09:03

AlexandrM


1 Answers

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
...
}
like image 158
King Jk Avatar answered Mar 17 '26 22:03

King Jk