We're using h2 (-1.2.130.jar) in a jboss server environment, where the
main database is mysql and h2 primarily provides a way to alias
various in-memory artifacts. Also, some of the mysql tables are set up
as linked tables like this:
create linked table
attribute('javax.naming.InitialContext','java:UIDatasource',NULL,NULL,'ATTRIBUTE')
READONLY
This works fine initially. However, if the jdbc connection from the h2
linked table to the jndi datasource is lost, it appears that it will
not reconnect.
I've set the jndi datasource connection parameters to avoid idle-
timeout, but sometimes the connection is lost anyway, leading to the
following error:
Error accessing linked table with SQL statement "SELECT * FROM
ATTRIBUTE T", cause: "com.mysql.jdbc.CommunicationsException:
Communications link failure due to underlying exception:
** BEGIN NESTED EXCEPTION **
java.net.SocketException
MESSAGE: Connection reset
STACKTRACE:
java.net.SocketException: Connection reset
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:96)
at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:
65)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:2744)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1612)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1723)
at com.mysql.jdbc.Connection.execSQL(Connection.java:3283)
at
com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:
1332)
at
com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:
1467)
at
org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeQuery(WrappedPreparedStatement.java:
342)
at org.h2.index.LinkedIndex.find(LinkedIndex.java:127)
at org.h2.index.IndexCursor.find(IndexCursor.java:127)
at org.h2.table.TableFilter.next(TableFilter.java:253)
at org.h2.command.dml.Select.queryFlat(Select.java:488)
at org.h2.command.dml.Select.queryWithoutCache(Select.java:555)
at org.h2.command.dml.Query.query(Query.java:233)
at org.h2.command.CommandContainer.query(CommandContainer.java:80)
at org.h2.command.Command.executeQuery(Command.java:132)
at org.h2.server.TcpServerThread.process(TcpServerThread.java:272)
at org.h2.server.TcpServerThread.run(TcpServerThread.java:131)
at java.lang.Thread.run(Thread.java:619)
Is there a way to automatically reconnect when this happens?
We can set up similar functionality using an alias that makes the
connection every time, but it is slower and doesn't get indexed like a
linked table.
Thanks,
Kim
--
You received this message because you are subscribed to the Google Groups "H2
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/h2-database?hl=en.