Question

I am new to Ruby on rails and I've recently created a small accounting application which connects to a sqlite3 database.

At the moment, I am still in development and I can save new data or update existing records on the database using the activerecord commands in the controller side.

But my questions is regarding JDBC with JRuby:

I am new to java as well and from what I understand, JRuby is made entirely of Java code and is being run on a JVM. And that there are gems that won't work if it is written in C.

If I start using JRuby instead of the MRI, what would be the difference? Will i still be using the active record commands in manipulating records in the database?

If I use JRuby and create a new application, does the JDBC adapters work exactly like an existing gem like sqlite3 to connect the application to the database?

Or I would only need to program the JDBC adapter instead of the controller?

I am a little confused of how it would work and a few information would be greatly appreciated. thank you in advance!

EDIT:

What I mean to ask is, currently my application is working on Ruby on Rails and I am using commands in the controller for example when you are updating existing records like this:

@variable = [Table_name].find(:id)

then

@variable.update_attributes(params[:submit])

This commands would update the record using RoR, but if using Rails in JRuby, how would this work? is it the same syntax?

Was it helpful?

Solution

JDBC is the Java API and driver to connect to a database.

Rails uses ActiveRecord as the ORM layer that is between the application and the database.

ActiveRecord will then use the driver specified to generate the SQL statements and migrations.

The calls will be always the same from the application side like you mentioned @variable = [Table_name].find(:id)

The difference will appear in the generated SQL statements in the logs and the generated migrations to suit the database driver specified.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top