DataMapper on JRuby

176 views
Skip to first unread message

Richard Conroy

unread,
Aug 10, 2010, 6:06:24 PM8/10/10
to datam...@googlegroups.com
Hi,
    I am doing a bit of prototyping with a Sinatra App that uses DataMapper (1.0) as the ORM layer.

I am just starting out with it, but in development mode I run the app on a JRuby container (Trinidad).

I am scratching my head here trying to get DataMapper to connect to any kind of simple local
development database (like sqlite3, or any of the JRuby database projects like hsqldb, Derby etc.).

Information is very sparse, out of date, or a lot of it applies to earlier versions of DataMapper.

Whats the state of JRuby support with DataMapper? There seems to be a bit of discussion on using
it with Google App Engine, but not much else.

Whats the simplest way to get a file based DB recognised in DataMapper with JRuby?

regards,
Richard.

kristian

unread,
Aug 11, 2010, 11:39:05 PM8/11/10
to DataMapper
as for now you can do the same with JRuby as with MRI - same DM
configuration. so basically you can choose between Sqlite3, Mysql,
Postgres (maybe oracle and sqlsercver) but the DM adapter for hsqldb,
h2, derby do not exist yet though the DataObject drivers are there.

so setup such a database you just need something like:

require 'dm-core'
DataMapper.setup(:default, "sqlite3:./test.db")

regards Kristian

On Aug 11, 3:06 am, Richard Conroy <richard.con...@gmail.com> wrote:
> Hi,
>     I am doing a bit of prototyping with a Sinatra App that uses DataMapper
> (1.0) as the ORM layer.
>
> I am just starting out with it, but in development mode I run the app on a
> JRuby container (Trinidad).
>
> I am scratching my head here trying to get DataMapper to connect to any l, kind

Richard Conroy

unread,
Aug 12, 2010, 4:48:25 AM8/12/10
to datam...@googlegroups.com
On Thu, Aug 12, 2010 at 4:39 AM, kristian <meier.k...@gmail.com> wrote:
as for now you can do the same with JRuby as with MRI - same DM
configuration. so basically you can choose between Sqlite3, Mysql,
Postgres (maybe oracle and sqlsercver) but the DM adapter for hsqldb,
h2, derby do not exist yet though the DataObject drivers are there.

so setup such a database you just need something like:

require 'dm-core'
DataMapper.setup(:default, "sqlite3:./test.db")

regards Kristian


Thanks Kristian,
     I did get it to work through trial and error, but oddly I had to stop using
sqlite3 and go back to sqlite (which I can gem install under jruby).

Information on what is actually supported is sparse to non-existent, that was
my biggest problem. I couldn't find any information on whether Java
specific DB projects were supported at all under datamapper, or whether
you could get them to work via a JDBC bridge.

There was some information with regards to compiling the support in, but even
that relates to older versions of DataMapper, and is likely to be invalid now that
the packages have been restructured with DM 1.0.

Just to be clear, I got my Sinatra app, which used sqlite & DataMapper running
transparently on MRI & JRuby. So if anyone else is having this problem - it can
be done, and quite easily too. Its just a documentation issue. The issues
arise due to the complexity of the gem dependency trees. You literally do not
know what gems to install.

I have been meaning to write up some of these experiences. If I get it down
clear enough, I will post a link, maybe save someone else some time. BTW the
experience is worth it: a nice tidy OS/Ruby VM portable Rack/Sinatra/DataMapper
stack.

regards,
Richard.
 
On Aug 11, 3:06 am, Richard Conroy <richard.con...@gmail.com> wrote:
> Hi,
>     I am doing a bit of prototyping with a Sinatra App that uses DataMapper
> (1.0) as the ORM layer.
>
> I am just starting out with it, but in development mode I run the app on a
> JRuby container (Trinidad).
>
> I am scratching my head here trying to get DataMapper to connect to any l, kind
> of simple local
> development database (like sqlite3, or any of the JRuby database projects
> like hsqldb, Derby etc.).
>
> Information is very sparse, out of date, or a lot of it applies to earlier
> versions of DataMapper.
>
> Whats the state of JRuby support with DataMapper? There seems to be a bit of
> discussion on using
> it with Google App Engine, but not much else.
>
> Whats the simplest way to get a file based DB recognised in DataMapper with
> JRuby?
>
> regards,
> Richard.
>
> --http://richardconroy.blogspot.com

--
You received this message because you are subscribed to the Google Groups "DataMapper" group.
To post to this group, send email to datam...@googlegroups.com.
To unsubscribe from this group, send email to datamapper+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/datamapper?hl=en.




--
http://richardconroy.blogspot.com

Dirkjan Bussink

unread,
Aug 28, 2010, 2:15:00 AM8/28/10
to datam...@googlegroups.com
Hello Richard,

> Thanks Kristian,
> I did get it to work through trial and error, but oddly I had to stop using
> sqlite3 and go back to sqlite (which I can gem install under jruby).

For DataMapper, you don't need any of the sqlite3, sqlite sqlite3-ruby or such gems. The only requirement is installing do_sqlite3. This has it's own binding to sqlite3, so it doesn't depend on any other gems.

> Information on what is actually supported is sparse to non-existent, that was
> my biggest problem. I couldn't find any information on whether Java
> specific DB projects were supported at all under datamapper, or whether
> you could get them to work via a JDBC bridge.

All the do_* drivers that are supported on JRuby actually use JDBC to bind to the drivers. So that's the case for do_sqlite3, do_mysql, do_postgres, do_hsqldb, do_h2, do_derby, do_oracle and do_sqlserver. For the database connectivity, you don't need anything besides those gems.

The whole gem installation process should therefore also be universal across different Ruby VM's. gem install datamapper dm-sqlite-adapter will install the necessary things for the relevant system. If this is not the case for you, or if this should be documented better, please let us know.

--
Regards,

Dirkjan Bussink

Dan Kubb (dkubb)

unread,
Aug 29, 2010, 10:20:16 PM8/29/10
to DataMapper
Richard,

> Just to be clear, I got my Sinatra app, which used sqlite & DataMapper
> running transparently on MRI & JRuby. So if anyone else is having this problem - it
> can be done, and quite easily too. Its just a documentation issue. The issues
> arise due to the complexity of the gem dependency trees. You literally do
> not know what gems to install.

I think what we were going for is that the gem installation process is
*exactly* the same between MRI and JRuby. If you have to go through
any other specific steps, then I would consider that a bug that we
need to fix.

The goal is that any tutorial that mentions getting started with
DataMapper work exactly the same for JRuby users (and Windows users
for that matter). Everything from the gem install commands, to the
connection strings, to the model setup and code should be the same. We
want to get to the point where platforms or OS is *not* mentioned
anywhere in the docs (other than to say "it's all the same across all
platforms").

Granted there is no support for native JRuby databases inside
DataMapper, that would be really easy to fix should someone be
interested in helping there. If those DBs support ANSI 92 SQL, then it
should mostly be a matter of inheriting from the DataObjectsAdapter,
and that's it. Take a look at the SQLite3, MySQL or PostgreSQL
adapters for an example -- I think the largest of them is around a
dozen lines long. You also need to look at the dm-migrations package
and confirm that the DDL statements that are executed are supported by
the DB.

The main reason there's no support for the native JRuby DBs is because
no one's asked for it. If someone is interested in setting one/all of
them up please let me know.

--

Dan

Charles Monteiro

unread,
Sep 25, 2013, 6:34:40 AM9/25/13
to datam...@googlegroups.com
wow, it does amaze me that there seems to be no call for Datamapper java database support , I'm using SqlLite with datamapper because I don't have any other choice for an embedded db solution, it would be nice to not depend on SqlLite and use Derby for example. I also do prefer DataMapper to ActiveRecord

christian

unread,
Sep 25, 2013, 6:50:28 AM9/25/13
to datam...@googlegroups.com
well, the DataObject drivers are there for the java databases but the respecitve datamapper-adapter are not.

I guess it should be pretty straight forward to write up such adapters.

but I always was happy to be able to switch between MRI and JRuby and still be able to use the same database so I never had the need for a java only database.

-christian


Reply all
Reply to author
Forward
0 new messages