I get a following exception on the thread interrupt. The exception comes
when "*nio*"* is used* while creating the connection (jdbc:h2:nio:test).
However, there is no exception if* nio is not used *(jdbc:h2:test)
org.h2.jdbc.JdbcSQLException: IO Exception:
"java.nio.channels.ClosedChannelException";
"nio:C:\Users\mehroa2\Desktop\test.h2.db" [90031-147]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:327)
at org.h2.message.DbException.get(DbException.java:156)
at org.h2.message.DbException.convertIOException(DbException.java:313)
at org.h2.store.FileStore.write(FileStore.java:342)
at org.h2.store.PageStore.writePage(PageStore.java:1309)
at org.h2.store.PageStreamData.write(PageStreamData.java:105)
at org.h2.store.PageOutputStream.storePage(PageOutputStream.java:148)
at org.h2.store.PageOutputStream.write(PageOutputStream.java:130)
at org.h2.store.PageLog.write(PageLog.java:529)
at org.h2.store.PageLog.commit(PageLog.java:549)
at org.h2.store.PageStore.commit(PageStore.java:1417)
at org.h2.engine.Database.commit(Database.java:1685)
at org.h2.engine.Session.commit(Session.java:459)
at org.h2.command.Command.stop(Command.java:170)
at org.h2.command.Command.executeUpdate(Command.java:250)
at
org.h2.jdbc.JdbcPreparedStatement.executeUpdateInternal(JdbcPreparedStatement.java:143)
at
org.h2.jdbc.JdbcPreparedStatement.executeUpdate(JdbcPreparedStatement.java:129)
at testH2.insert(testH2.java:33)
at testH2$1.run(testH2.java:43)
at java.lang.Thread.run(Thread.java:722)
Following is the sample program
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
/**
* A very simple class that shows how to load the driver, create a database,
* create a table, and insert some data.
*/
public class testH2 {
static Connection conn = null;
static PreparedStatement statP = null;
static{
try {
Class.forName("org.h2.Driver");
conn =
DriverManager.getConnection("jdbc:h2:nio:C:\\Users\\mehroa2\\Desktop\\test");
statP = conn.prepareStatement("insert into test1 values(1,
'Hello')");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void insert() throws SQLException{
statP.executeUpdate();
}
public static void main(String... args) throws Exception {
Thread t = new Thread(new Runnable(){
public void run(){
testH2 t = new testH2();
for (int i=0;i<50000;i++){
try {
t.insert();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
);
t.start();
Thread.sleep(1);
t.interrupt();
testH2 tx = new testH2();
tx.insert();
}
}
Any pointers on understanding this behavior would be highly appreciated.
Thanks in advance.
--
You received this message because you are subscribed to the Google Groups "H2
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/h2-database?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.