I was surprised to find out the following code doesn't work. It doesn't seem to pick up my changes on the Connection class, nor did it work on ResultSet. Then I remembered they're both interfaces, and so changes there aren't getting picked up by incoming objects that implement them.

Where do we stand on the best way to do this? I want it.

include Java

import java.sql.Connection
import java.sql.DriverManager
import java.sql.ResultSet

java.lang.Class.for_name("com.mysql.jdbc.Driver")

class Connection
  def execute(query)
    statement = create_statement
    results = statement.execute_query(query)
    yield results
  ensure
    results.close if results
    statement.close if statement
  end
end

begin
connection = DriverManager.get_connection("jdbc:mysql://localhost/mephisto_development", "mephisto", "mephisto")

  connection.execute("select * from users") do |results|
    puts results.get_string("email") while results.next
  end
ensure
  connection.close if connection
end

---------------------------------------------------------------------
To unsubscribe from this list please visit:

   http://xircles.codehaus.org/manage_email

Reply via email to