Linked table to SQLite db table

13 views
Skip to first unread message

MicheleDG

unread,
Mar 17, 2009, 2:14:54 PM3/17/09
to H2 Database
Hi all,
I'm trying to create a linked table in H2 that could retrieve data
from a SQLite db table with the following command :

CREATE LINKED TABLE TblTest('org.sqlite.JDBC','jdbc:sqlite:/home/
michele/test.db','','','TblTest');

but I get the following error :

General error: java.lang.ArrayIndexOutOfBoundsException: -1; SQL
statement:
CREATE LINKED TABLE TblTest('org.sqlite.JDBC','jdbc:sqlite:/home/
michele/test.db','','','TblTest') [50000-108] HY000/50000 (Aiuto)
org.h2.jdbc.JdbcSQLException: General error:
java.lang.ArrayIndexOutOfBoundsException: -1; SQL statement:
CREATE LINKED TABLE TblTest('org.sqlite.JDBC','jdbc:sqlite:/home/
michele/test.db','','','TblTest') [50000-108]
at org.h2.message.Message.getSQLException(Message.java:107)
at org.h2.message.Message.convert(Message.java:278)
at org.h2.command.Command.executeUpdate(Command.java:230)
at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:165)
at org.h2.server.web.WebThread.getResult(WebThread.java:1723)
at org.h2.server.web.WebThread.query(WebThread.java:1286)
at org.h2.server.web.WebThread.process(WebThread.java:444)
at org.h2.server.web.WebThread.processRequest(WebThread.java:186)
at org.h2.server.web.WebThread.process(WebThread.java:241)
at org.h2.server.web.WebThread.run(WebThread.java:196)
Caused by: java.lang.ArrayIndexOutOfBoundsException: -1
at org.h2.util.ObjectArray.set(ObjectArray.java:179)
at org.h2.table.TableLink.readMetaData(TableLink.java:207)
at org.h2.table.TableLink.connect(TableLink.java:88)
at org.h2.table.TableLink.<init>(TableLink.java:71)
at org.h2.schema.Schema.createTableLink(Schema.java:500)
at org.h2.command.ddl.CreateLinkedTable.update
(CreateLinkedTable.java:78)
at org.h2.command.CommandContainer.update(CommandContainer.java:
71)
at org.h2.command.Command.executeUpdate(Command.java:207)
... 7 more

Maybe the error is due to the SQLite jdbc connector or am I doing
something wrong ?
I'm running H2 1.1.108 (2009-02-28) on JRE 1.6.0_12-b04 (Linux).
Thanks a lot for your kind help and suggestions

Michele

Thomas Mueller

unread,
Mar 18, 2009, 2:59:11 PM3/18/09
to h2-da...@googlegroups.com
Hi,

This is a bug in the JDBC driver of SQLite. I will add a workaround
for it in the next release. The workaround is:

TableLink.java
private void readMetaData() throws SQLException {
...
String col = rs.getString("COLUMN_NAME");
col = convertColumnName(col);
Column column = (Column) columnMap.get(col);
// workaround start
if (idx == 0) {
// workaround for SQLite
list.add(column);
} else {
list.set(idx - 1, column);
}
// workaround end
...
}

Regards,
Thomas

MicheleDG

unread,
Mar 20, 2009, 5:49:42 AM3/20/09
to H2 Database
Hi Thomas,
thanks a lot for your kind reply and for your effort to fix this
problem, even if it's not H2 dependent.
Best regards, have a nice day.

Michele

On Mar 18, 7:59 pm, Thomas Mueller <thomas.tom.muel...@gmail.com>
wrote:
> Hi,
>
> This is a bug in the JDBC driver ofSQLite. I will add a workaround
Reply all
Reply to author
Forward
0 new messages