DataMapper and SQLITE3 with JRUBY 1.6.3

I am working on a small sintra app and using jruby and datamapper. I
used
ruby and this worked fine as well as deployed to heroku which also
works. I
copied the code over to a jruby machine and i can’t seem to get the
DataMapper code to work. I know that i need extra libraries for sqlite3
to
work under jruby but i am unable to get datamapper to see or create my
database. It tells me it cant find the database and i get a “can’t
connect”
error. Further down the trace i get another message saying " ‘\’ does
not
exist (code: , sql state: , query: , uri: )". I have no idea what this
refers to. I am using DataMapper.setup(:default,
“sqlite3://#{Dir.pwd}/db/database.db”).
Any ideas?

Thanks,
–Nick

On Mon, Aug 8, 2011 at 11:30 PM, Nick H. [email protected] wrote:

Any ideas?
Thanks,
–Nick

yes, 2 ideas:

1/ for the db url, since this is jruby, you should go for jdbc sqlite
driver => ‘jdbc:sqlite:etc…’. You’ll need a jdbc driver (like
sqlite-jdbc-3.7.2.jar, just google for it)

2/ drop sqlite for h2 database since you’re using jruby: you should
get a much faster db this way, without breaking your code (at least
with sequel it works out of the box).

Currently, I’m doing some sinatra dev with jruby/h2 and mri/sqlite.


Christian

On Tue, Aug 9, 2011 at 3:00 AM, Nick H. [email protected] wrote:

. I know that i need extra libraries for sqlite3 to work under jruby but i
am unable to get datamapper to see or create my database.

so first you need to make sure you do install the java versions of the
dataobjects gems. probably something like “jruby -S gem update
do_sqlite3” shall do.

when I do

require ‘rubygems’
require 'dm-sqlite-adapter
DataMapper.setup(:default, “sqlite3://#{Dir.pwd}/db/database.db”)

things work fine with jruby-1.6.3 - hope that helps a bit.

  • Kristian

On Tue, Aug 9, 2011 at 12:45 AM, Christian MICHON
[email protected] wrote:

“sqlite3://#{Dir.pwd}/db/database.db”).
sqlite-jdbc-3.7.2.jar, just google for it)

2/ drop sqlite for h2 database since you’re using jruby: you should
get a much faster db this way, without breaking your code (at least
with sequel it works out of the box).

Currently, I’m doing some sinatra dev with jruby/h2 and mri/sqlite.


Christian

Regarding my 2 points: I did not check if dm-core would support jdbc
adapters out of the box, especially h2 over jdbc.

Apparently, this repo
(GitHub - bernerdschaefer/dm-jdbc-adapter: JDBC Adapter for DM) contains a jdbc
adpater for dm-core, but it contains only what is needed to make mysql
or sqlite work over jdbc.

Sorry again.

Rgds,
Christian

Nick H. wrote in post #1015568:

I am working on a small sintra app and using jruby and datamapper. I
used
ruby and this worked fine as well as deployed to heroku which also
works. I
copied the code over to a jruby machine and i can’t seem to get the
DataMapper code to work. I know that i need extra libraries for sqlite3
to
work under jruby but i am unable to get datamapper to see or create my
database. It tells me it cant find the database and i get a “can’t
connect”
error. Further down the trace i get another message saying " ‘\’ does
not
exist (code: , sql state: , query: , uri: )". I have no idea what this
refers to. I am using DataMapper.setup(:default,
“sqlite3://#{Dir.pwd}/db/database.db”).
Any ideas?

Thanks,
–Nick

I’m getting this problem as well. I’m on Windows. Something is stripping
out a colon (from “c:/…”). On a hunch I removed the “//” part of the
connection string and it worked fine:
“sqlite3:#{Dir.pwd}/db/database.db”.