Subject RE: [IB-Java] interclient and JRun pooled connections
Author Peter Wilkinson
I've been trying to get to the bottom of this and still can't get the
connections to commit. The only way I can get the servlet to see the new
entries in the db is by restarting JRun, which kills the pooled connections.

I've also tried the same code in Orionserver and I get the same results. I'm
wondering now if these pooled sources require JDBC2.0 support in the driver.

Is there a compiled version of Interclient 2 anywhere that I can try, I've
had a look at the source and the build process looks a bit nasty?

The source I'm using to test is:

37 InitialContext ctx = null;
38 try {
39 // Define JNDI InitialContext object.
40 ctx = new InitialContext();
41 // Look up data source in InitialContext.
42 DataSource ds =
43 (DataSource) ctx.lookup("java:comp/env/jdbc/" +
dsName);
44 dbCon = ds.getConnection();
45 dbCon.setAutoCommit(true);
46
47
48 if (dbCon.getAutoCommit())
49 out.println("<br>AUTO COMMIT<br>");
50 else
51 out.println("<br>NOT AUTO COMMIT<br>");
52
53 // Create Statement object.
54 dbStmt = dbCon.createStatement();
55 // Execute the query.
56 dbRS = dbStmt.executeQuery(sqlStmt);
57
58 out.println("<br>");
59 out.println("Log entries...<br>");
60 while (dbRS.next()) {
61 out.println(dbRS.getDate("entry_date") + "<br>");
62 }
63
64 dbRS.close();
65 dbRS = null;
66
67 out.println("<br>");
68 out.println("Num Log entries for today...<br>");
69
70 sqlStmt = "select count(*) from get_entries_today(1)";
71 dbRS = dbStmt.executeQuery(sqlStmt);
72 while (dbRS.next()) {
73 out.println(dbRS.getInt("count") + "<br>");
74 }
75
76 } catch (Exception e) {
77 out.println("Unable to establish a connection through
the driver manager.");
78 out.println("ERR:<br><pre>" + e + "</pre>");
79 } finally {
80 // close db resources
81 try {
82 if (dbRS != null) {
83 dbRS.close();
84 }
85 if (dbStmt != null) {
86 dbStmt.close();
87 }
88 if (dbCon != null) {
89 dbCon.close();
90 }
91 ctx.close();
92 } catch (Exception sqlex) {
93 out.println("<p>SQL exception in finally block");
94 sqlex.printStackTrace();
95 }
96 }

This never throws an exception and will always show "AUTO COMMIT" form line
48 and always gets the records from the db as it was when JRun or
Orionserver started.

Help!!!

PeterW.


-----Original Message-----
From: Alexander Sokolov [mailto:sokolov@...]

Peter Wilkinson wrote:
>
> Hi,
>
> I've just set up JRun to use Interclient in pools. I am having some
problems
> getting the sequence of commits correct so that my servlet will see and
> commits made since the JRun server has started.
>
> Does anyone know what I need to do to get Interclient to work in a pool
such
> that it sees all current committed transactions???

Try

Connection con=DriverManager.getConnection(dbURL,userName,passwd);
con.setAutoCommit(true);

I did not try this in a servlet but it works well for me in case of
RMI server, which comminicates with a database using interclient

Alexander