Re: Setting Query Timeout through JDBC (CA Driver problem?)
- From: izena@xxxxxxxxxxx
- Date: 25 Apr 2006 02:59:10 -0700
I suggest (strongly) to you not using commands like ""set lockmode ..."
inside jdbc because they are not intended for being used like that nor
supported. So you can get unexpected and sometimes bizarre results
quite hard to follow. The type of everything is ok on tests and later
someday in production everything is collapsed by locks and nobody knows
really why (pooling, affairs of concurrency, etc).
After this warning, and if you are still thinking to go on, this piece
of code (not ours) should work (or does it some years ago) Use it at
your own risk.
try {
myStmt = myConn.createStatement();
myStmt.execute("set trace point rd020"); // Seems to disable
iisynonym locks (obsolete ?)
myStmt.execute("set lockmode session where timeout=40");
myConn.commit();
}
As mentioned, the pooling, the way your application is coded etc, (or
even if it will be supported in later versions of ingres through jdbc)
does not assure that it will work as you think.
I found missing in your code the transaction mode setting. If you plan
to read and make no lock it should be something like this
ingConn = getConnection(....)
ingConn.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
ingStmt = ingConn.createStatement();
ingRset = ingStmt.executeQuery(aReadOnlyQuery);
About query timeout we have not used it, but I do not remember any
place that says that it is unsupported in ingres JDBC. But it could
not, I do not know.
We work too with uPortal (sometimes channels or checks inside Uportal
use ingres) . If you want I can give you more details offline.
Carlos
(losalo atsign unavarra dotsign es)
mark.berry@xxxxxxxxxxxxxxxx ha escrito:
I've been trying to set a timeout for my Ingres queries, but I can't
seem to get the necessary statements through the CA JDBC driver.
I'm using the CA driver (ca.edbc.jdbc.EdbcDriver), from a java channel
running inside uPortal, to connect to Ingres SPARC SOLARIS Version II
2.6/0201 (su4.us5/00) running on SunOS 5.9.
My first try was to pass through the following command just like a
regular query, immediately before the actual query:
set lockmode session where readlock=nolock, timeout=2
However, this produces a syntax error and says the correct syntax would
be
'OPEN CURSORID CURSOR FOR fullselect....'
I take this to be an error from within the JDBC driver rather than
coming from Ingres itself.
I've then tried to change my java code to call the query in various
different ways, but they all fail with syntax errors.
I've also tried the direct route through the JDBC command:
stmt.setQueryTimeout(2);
I've got this to work fine for connecting to SQL Server databases but
it doesn't seem to have any effect on my Ingres queries.
My java code for running the lockmode query is:
try
{
con = getConnection(jdbcDriver, jdbcUrl, jdbcUser,
jdbcPassword, RETRY_COUNT, prevErrorMsg);
stmt =
con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
rs = stmt.executeQuery("set lockmode session where
readlock=nolock, timeout=2");
}
catch (SQLException sqle)
{
etc
As I've been reading aound this subject, I've recently read comments
suggesting that my attempted method could in any case be problematic
because of connection pooling, which may mean that the timeouts I set
will be applied to any other queries sharing the same session. However
for now I can't even get these timeout settings through at all. If I
could, maybe I could deal with the connection pooling problems by
resetting the session timeout to 0 (unlimited) immediately after
running each query?
For now, though, the first question is simply whether the CA drivers
support setQueryTimeout(), and if not, how can I set a timeout for a
query? (I need to set different length timeouts for different queries
so a global setting wouldn't solve my problem).
Many thanks,
Mark Berry
ELVI Portal (Web) Developer
University of Nottingham
.
- Follow-Ups:
- Re: Setting Query Timeout through JDBC (CA Driver problem?)
- From: mark.berry@xxxxxxxxxxxxxxxx
- Re: Setting Query Timeout through JDBC (CA Driver problem?)
- From: izena
- Re: Setting Query Timeout through JDBC (CA Driver problem?)
- From: Roy Hann
- Re: Setting Query Timeout through JDBC (CA Driver problem?)
- References:
- Setting Query Timeout through JDBC (CA Driver problem?)
- From: mark.berry@xxxxxxxxxxxxxxxx
- Setting Query Timeout through JDBC (CA Driver problem?)
- Prev by Date: Installation experience (was Re: [Info-ingres] Re: Pagesize question)
- Next by Date: RE: [Info-ingres] Scheduled SQL Job pulling from Ingres Fails
- Previous by thread: Setting Query Timeout through JDBC (CA Driver problem?)
- Next by thread: Re: Setting Query Timeout through JDBC (CA Driver problem?)
- Index(es):
Relevant Pages
|