Jdbc template error

Hi,
I’m attempting to invoke Spring’s JdbcTemplate from JRuby. Everything
looks
fine, but when i call the “update” method passing my sql string an
Object[]
it gives me this error:

16:09:17,781 INFO [DriverManagerDataSource] Loaded JDBC driver:
oracle.jdbc.driver.OracleDriver
lib/cdf/jdbc.rb:17:in `invoke’: no update with arguments matching [class
org.jruby.RubyString, class org.jruby.RubyArray] on object #<Java::
OrgSpringframeworkJdbcCore::JdbcTemplate:0x1a70b8
@java_object=org.springframework.jdbc.core.JdbcTemplate@1de6817>
(NameError)

I uploaded the file. Thanks for any help.
http://www.nabble.com/file/p22088312/jdbc.rb jdbc.rb

View this message in context:
http://www.nabble.com/jdbc-template-error-tp22088312p22088312.html
Sent from the JRuby - User mailing list archive at Nabble.com.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

I believe you need to do a sqlarray.to_java, or possibly a
sqlarray.to_java(:string), or sqlarray.to_java(java.lang.String[])

Hope that helps.

On Wed, Feb 18, 2009 at 1:12 PM, ben.hidalgo [email protected]
wrote:

OrgSpringframeworkJdbcCore::JdbcTemplate:0x1a70b8
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

I didn’t get a chance to try the suggestion, but switching to
NamedParameterJdbcTemplate fixed the problem. It accepts a sql string
and
Map (Hash), which was how my data was naturally. It uses smart
defaulting
like “foo” substitutes :foo so you don’t have to pre process.

require ‘java’

require ‘jars/spring-2.5.6.jar’
require ‘jars/commons-logging.jar’
require ‘jars/ojdbc14.jar’

import ‘org.springframework.jdbc.datasource.DriverManagerDataSource’
import
‘org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate’

ds = DriverManagerDataSource.new
ds.driver_class_name = JDBC[:driver_class_name]
ds.url = JDBC[:url]
ds.username = JDBC[:username]
ds.password = JDBC[:password]

NamedParameterJdbcTemplate.new(ds).update(sql,hash)


View this message in context:
http://www.nabble.com/jdbc-template-error-tp22088312p22111274.html
Sent from the JRuby - User mailing list archive at Nabble.com.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email