AnsweredAssumed Answered

JDBC getColumns() failing sporadically

Question asked by DavePijuan-Nomura on Apr 24, 2013


JDBC getColumns() failing sporadically

Your post

     I'm trying to get a table schema using the getColumns() function, and sometimes it works, but sometimes it returns an empty result set, and occasionally, it raises a "Java::ComFilemakerJdbc::FMSQLException: [FileMaker][FileMaker JDBC] Invalid name in metadata query." exception. I'm using driver version 12.3.103 via jRuby.

     The code is jRuby, but it maps pretty well to Java:


     require 'java'
     require "fmjdbc.jar"
     java_import 'com.filemaker.jdbc.Driver'
     @host = config['host']
     @username = config['username']
     @password = config['password']
     @database = config['source']
     @connection ||= JavaSql::DriverManager.getConnection("jdbc:filemaker://#{@host}/#{@database}?user=#{@username}&password=#{@password}")
     s = @connection.createStatement()
     rs = s.getColumns(nil,'contacts')
     metadata = rs.getMetaData()
     ncols = metadata.getColumnCount()
     schema_keys = (1..ncols).collect{ |i| metadata.getColumnName(i) }
     rows = []
       rows << (1..ncols).inject({}){ |a, i| a[schema_keys[i - 1]] = rs.getString(i);a}
     I found no documentation for the getColumns() function, and have no idea what the first parameter does. If anyone can shed some light on this problem, it would be immensely appreciated.