Using shared in-memory - anyone got a working JDBC url example

2,820 views
Skip to first unread message

Kit Kline

unread,
Sep 2, 2012, 2:58:55 PM9/2/12
to xer...@googlegroups.com
Hi all,

I'm trying to use a shared in-memory db. So from the documentation (http://www.sqlite.org/inmemorydb.html) the JDBC url should be something like:

jdbc:sqlite:file:memdb1?mode=memory&cache=shared

But that's not running in mem it's making a file called:     file:memdb1?mode=memory&cache=shared 
Plain old in-mem: jdbc:sqlite::memory: works fine - but I need one shared

Is the URI file: protocal supported by xerial? And  if so, what should the JDBC url look like?

Any help much appreciated

Cheers

Kit

Grace B

unread,
Feb 18, 2013, 8:17:24 AM2/18/13
to xer...@googlegroups.com
No, the URI file protocol is not supported by xerial. 
A request for enhancement has been created at https://bitbucket.org/xerial/sqlite-jdbc/issue/42

Grace B

unread,
Mar 2, 2013, 11:24:30 PM3/2/13
to xer...@googlegroups.com

JDBC URL examples are based on http://www.sqlite.org/inmemorydb.html
1. Unnamed memory db: "jdbc:sqlite::memory:?cache=shared"
2. Named memory db: "jdbc:sqlite:memdb1?mode=memory&cache=shared"

Peter Borissow

unread,
Mar 16, 2013, 12:21:31 PM3/16/13
to xer...@googlegroups.com
Hi Grace-
    Would it be possible to get a new snapshot so I can test this out?

Thanks!
Peter



From: Grace B <grace.b...@gmail.com>
To: xer...@googlegroups.com
Sent: Saturday, March 2, 2013 11:24 PM
Subject: [xerial 664] Re: Using shared in-memory - anyone got a working JDBC url example

--
You received this message because you are subscribed to the Google Groups "Xerial" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xerial+un...@googlegroups.com.
To post to this group, send email to xer...@googlegroups.com.
Visit this group at http://groups.google.com/group/xerial?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 


Peter Borissow

unread,
Mar 22, 2013, 11:07:21 AM3/22/13
to xer...@googlegroups.com
I have a requirement for an in-memory db and would really like to try out this new feature before considering other options.

Can we please get a new snapshot?

Thanks in Advance!
Peter



From: Peter Borissow <peter.b...@yahoo.com>
To: "xer...@googlegroups.com" <xer...@googlegroups.com>
Sent: Saturday, March 16, 2013 12:21 PM
Subject: Re: [xerial 664] Re: Using shared in-memory - anyone got a working JDBC url example

Grace B

unread,
Mar 22, 2013, 9:52:57 PM3/22/13
to xer...@googlegroups.com, Peter Borissow
Uploaded for windows and linux snapshot https://bitbucket.org/xerial/sqlite-jdbc/downloads

I do not have a Mac.

Regards,
Grace

Peter Borissow

unread,
Mar 23, 2013, 8:50:19 AM3/23/13
to Grace B, xer...@googlegroups.com
Thanks Grace!

Unfortunately, I haven't been able to get it to work. I'm using java 1.6 on windows 7 x64 with the latest snapshot. I'm trying to open a connection with "java.sql.Driver.connect(url, properties)" and I'm getting the following errors:


URL: jdbc:sqlite::memory:?cache=shared
java.sql.SQLException: opening db: ':memory:?cache=shared': The filename, directory name, or volume label syntax is incorrect
        at org.sqlite.Conn.open(Conn.java:152)
        at org.sqlite.Conn.<init>(Conn.java:87)
        at org.sqlite.JDBC.createConnection(JDBC.java:113)
        at org.sqlite.JDBC.connect(JDBC.java:87)



URL: jdbc:sqlite:memdb1?cache=shared&mode=memory
java.sql.SQLException: opening db: 'memdb1?cache=shared&mode=memory': The filename, directory name, or volume label syntax is incorrect
        at org.sqlite.Conn.open(Conn.java:152)
        at org.sqlite.Conn.<init>(Conn.java:87)
        at org.sqlite.JDBC.createConnection(JDBC.java:113)
        at org.sqlite.JDBC.connect(JDBC.java:87)




Any thoughts? Is the url in these 2 examples correct?


Thanks Again,
Peter





Cc: Peter Borissow <peter.b...@yahoo.com>
Sent: Friday, March 22, 2013 9:52 PM

Subject: Re: [xerial 664] Re: Using shared in-memory - anyone got a working JDBC url example

Grace B

unread,
Mar 23, 2013, 5:16:42 PM3/23/13
to xer...@googlegroups.com, Grace B, Peter Borissow
Oops,
That was my mistake. My earlier post should have included "file:" in the JDBC as outlined on http://www.sqlite.org/inmemorydb.html

Correct URL format is:

1. Unnamed memory db: "jdbc:sqlite:file::memory:?cache=shared"
2. Named memory db: "jdbc:sqlite:file:memdb1?mode=memory&cache=shared"

Peter Borissow

unread,
Mar 23, 2013, 6:35:04 PM3/23/13
to Grace B, xer...@googlegroups.com
I added the missing ":file" to the URL but it still doesn't seem to work. Any other suggestions?

Again, I'm using "sqlite-jdbc-3.7.15-SNAPSHOT-1-win-linux.jar" on Windows 7 x64 with Java 1.6.

Thanks,
Peter


Cc: Grace B <grace.b...@gmail.com>; Peter Borissow <peter.b...@yahoo.com>
Sent: Saturday, March 23, 2013 5:16 PM

Subject: Re: [xerial 664] Re: Using shared in-memory - anyone got a working JDBC url example
Oops,
That was my mistake. My earlier post should have included "file:" in the JDBC as outlined on http://www.sqlite.org/inmemorydb.html

Correct URL format is:

1. Unnamed memory db: "jdbc:sqlite:file::memory:?cache= shared"
2. Named memory db: "jdbc:sqlite:file:memdb1?mode= memory&cache=shared"


On Saturday, March 23, 2013 8:50:19 AM UTC-4, Peter wrote:
Thanks Grace!

Unfortunately, I haven't been able to get it to work. I'm using java 1.6 on windows 7 x64 with the latest snapshot. I'm trying to open a connection with "java.sql.Driver.connect(url, properties)" and I'm getting the following errors:


URL: jdbc:sqlite::memory:?cache= shared
java.sql.SQLException: opening db: ':memory:?cache=shared': The filename, directory name, or volume label syntax is incorrect
        at org.sqlite.Conn.open(Conn. java:152)
        at org.sqlite.Conn.<init>(Conn. java:87)
        at org.sqlite.JDBC. createConnection(JDBC.java: 113)
        at org.sqlite.JDBC.connect(JDBC. java:87)



URL: jdbc:sqlite:memdb1?cache= shared&mode=memory
java.sql.SQLException: opening db: 'memdb1?cache=shared&mode= memory': The filename, directory name, or volume label syntax is incorrect

        at org.sqlite.Conn.open(Conn. java:152)
        at org.sqlite.Conn.<init>(Conn. java:87)
        at org.sqlite.JDBC. createConnection(JDBC.java: 113)
        at org.sqlite.JDBC.connect(JDBC. java:87)

Grace B

unread,
Mar 24, 2013, 2:28:04 PM3/24/13
to xer...@googlegroups.com, Grace B, Peter Borissow
Please use the latest snapshot from https://bitbucket.org/xerial/sqlite-jdbc/downloads.

Regards,
Grace

Peter Borissow

unread,
Mar 24, 2013, 4:43:54 PM3/24/13
to Grace B, xer...@googlegroups.com
Hi Grace-
   I downloaded the latest snapshot ("sqlite-jdbc-3.7.15-SNAPSHOT-2.jar") and it seems to be working now! At least, I'm able to open a connection without any errors. I'll play with it some more and let you know if I find any other issues.

Thanks!
Peter



From: Grace B <grace.b...@gmail.com>
To: xer...@googlegroups.com
Cc: Grace B <grace.b...@gmail.com>; Peter Borissow <peter.b...@yahoo.com>
Sent: Sunday, March 24, 2013 2:28 PM

Subject: Re: [xerial 664] Re: Using shared in-memory - anyone got a working JDBC url example
Please use the latest snapshot from https://bitbucket.org/xerial/sqlite-jdbc/downloads.

Regards,
Grace


On Saturday, March 23, 2013 6:35:04 PM UTC-4, Peter wrote:
I added the missing ":file" to the URL but it still doesn't seem to work. Any other suggestions?

Again, I'm using "sqlite-jdbc-3.7.15-SNAPSHOT- 1-win-linux.jar" on Windows 7 x64 with Java 1.6.

Thanks,
Peter


Ashiq A.

unread,
Feb 11, 2014, 6:13:13 PM2/11/14
to xer...@googlegroups.com, Grace B, Peter Borissow
Did this break in the latest production version on Maven?

When I use an in-memory DB using the syntax below, and create my tables in the first SQL call, I get a "table doesn't exist" error.

If I switch to a file-based DB, I don't get any errors.

Below are the two "connection strings" I used; the second works.

1) jdbc:sqlite:file::memory:?cache=shared
2) jdbc:sqlite:file:test.sqlite3

--Ashiq

Eric Zuo

unread,
Jul 12, 2018, 9:49:34 AM7/12/18
to Xerial
Same here.

Can we get some kind suggestions here?
Reply all
Reply to author
Forward
0 new messages