B-Sides / peacekeeper

Peacekeeper handles delegation to a variety of ORMs and separation of business logic from persistance logic
BSD 2-Clause "Simplified" License
1 stars 1 forks source link

Error with sequel db uri when specifying a jdbc:mysql connection #2

Closed tapn2it closed 12 years ago

tapn2it commented 12 years ago

Error: jruby-1.6.7 :014 > DB = Sequel.connect('jdbc:mysql://root:@localhost/table_saver_dev?user=root') => #<Sequel::JDBC::Database: "jdbc:mysql://root:@localhost/table_saver_dev?user=root"> jruby-1.6.7 :015 > DB[:restaurants].all Sequel::DatabaseConnectionError: NativeException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Cannot load connection class because of underlying exception: 'java.lang.NumberFormatException: For input string: "@localhost"'. NativeException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Cannot load connection class because of underlying exception: 'java.lang.NumberFormatException: For input string: "@localhost"'.

Cause: Looks like Sequel jdbc adapter is expecting a different format for connection uri. While Sequel doc implies that all document Sequel uri formats are valid, it didn't seem to be the case with JDBC.

Works: I found the following uri format works:

adapter = 'jdbc:mysql' host = 'localhost' database = 'table_saver_dev' username = 'root' password = ""

    "#{config['adapter']}://#{config['host']}/#{config['database']}?user=#{config['username']}&password=#{config['password']}"
jballanc commented 12 years ago

Fixed with 2f6dbd2804. Thanks Victor!