Groovy method "no signature" String argument and String return -


i have beginner question using groovy. had thought simple, unchallenging code snippet.

  def getname( str ){     def rslt = "(none)";     str.eachmatch( /$[table_name:[a-za-z]]^/ ){         -> patrn          if( "(none)" == rslt ){             rslt = patrn;         }     }//eachmatch      return rslt; }//getname 

the idea return first match regex string 'str' passed, , matching string in 'rslt'.

instead have kind of error.

exception in thread "main" groovy.lang.missingmethodexception:      no signature of method: all_tables$_main_closure1.getname()        applicable argument types: (org.codehaus.groovy.runtime.gstringimpl)          values: [action]          possible solutions: getat(java.lang.string), getat(java.lang.string)            @ org.codehaus.groovy.runtime.metaclass.closuremetaclass.invokemethod(closuremetaclass.java:379)           @ groovy.lang.metaclassimpl.invokemethod(metaclassimpl.java:909)           @ groovy.lang.metaclassimpl.invokemethod(metaclassimpl.java:730)           @ ...           @ all_tables$_main_closure1.docall(all_tables.groovy:31)           @ ...           @ groovy.sql.sql.eachrow(sql.java:1186)           @ ...            @ all_tables.main(all_tables.groovy:26) 

the call, seemed straightforward:

static void main( string args[] ){     def sql = sql.newinstance(             "jdbc:mysql://dev:3306/dbname",             "dbuser", "dbpass", "com.mysql.jdbc.driver" );      sql.eachrow( "show tables;" ){         str = it[0].tostring();         nam = getname( str );     };  }//main 

what curled toes groovy documents mention basic java , groovy libraries (such java.lang.string) included. yet signature fails on string.

i know much. when small piece of code jruby, works. none of 'signature' nonsense.

... advice welcome :-)

will

it's hard exact omit lot of context question, looks trying call non-static method static main method.

try either making getname static, or call on instance of enclosing class


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -