Forum: JRuby jdbc template error

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
ben.hidalgo (Guest)
on 2009-02-18 23:13
(Received via mailing list)
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-tp220883...
Sent from the JRuby - User mailing list archive at Nabble.com.


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

    http://xircles.codehaus.org/manage_email
Johnny P (Guest)
on 2009-02-19 01:57
(Received via mailing list)
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 
<removed_email_address@domain.invalid>
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
ben.hidalgo (Guest)
on 2009-02-20 00:44
(Received via mailing list)
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-tp220883...
Sent from the JRuby - User mailing list archive at Nabble.com.


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

    http://xircles.codehaus.org/manage_email
This topic is locked and can not be replied to.