Subject | Re: Firebird and multiple threads |
---|---|
Author | fabiano_bonin |
Post date | 2006-05-29T14:51:10Z |
> What error do you get? Which version of Jaybird do you use?Thread-0 - org.firebirdsql.jdbc.FBSQLException: The result set is closed
>
Thread-1 - null
My test consist of two very simple java files.
This is the main one:
import java.sql.*;
public class Teste {
public static void main(String[] args) {
try {
Class.forName("org.firebirdsql.jdbc.FBDriver");
Connection conn = DriverManager.getConnection(
"jdbc:firebirdsql:127.0.0.1/3050:employee",
"sysdba", "masterkey");
System.out.println(new Time(System.currentTimeMillis()));
new ThreadResultSet(conn, "select * from rdb$database");
new ThreadResultSet(conn, "select * from rdb$database");
System.out.println(new Time(System.currentTimeMillis()));
} catch (Exception E) {
System.out.println(E);
}
}
}
And this is the other one:
package jdbc;
import java.sql.*;
public class ThreadResultSet implements Runnable {
private Statement stmt;
private ResultSet rs;
private String sql;
private Thread thr;
public ThreadResultSet(Connection conn, String sql) throws Exception {
stmt = conn.createStatement();
this.sql = sql;
thr = new Thread(this);
thr.start();
}
public void run() {
try {
rs = stmt.executeQuery(sql);
rs.next();
System.out.println(thr.getName() + " - " + rs.getString(1));
stmt.close();
} catch (SQLException E) {
System.out.println(thr.getName() + " - " + E.toString());
}
}
}
Regards,
Fabiano.