Re: getAutocommit assertion error

From: rob stone <floriparob(at)gmail(dot)com>
To: adrien ruffie <adriennolarsen(at)hotmail(dot)fr>, "pgsql-jdbc(at)lists(dot)postgresql(dot)org" <pgsql-jdbc(at)lists(dot)postgresql(dot)org>
Subject: Re: getAutocommit assertion error
Date: 2018-11-14 14:42:16
Message-ID: 11e772e66843f44261d302615c438357203b6da2.camel@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hello,

> > > private booleanisAutoCommit() {
> > > try {
> > > return pgStatement.getConnection().getAutoCommit();
> > > } catch (SQLException e) {
> > > assert false : "pgStatement.getConnection().getAutoCommit()
> > > should not throw";
> > > return false;
> > > }
> > > }

From the doco:-

----
public static Connection getConnection(String url,
Properties info)
throws SQLException

Attempts to establish a connection to the given database URL. The
DriverManager attempts to select an appropriate driver from the set of
registered JDBC drivers.

Parameters:
url - a database url of the form jdbc:subprotocol:subname
info - a list of arbitrary string tag/value pairs as connection
arguments; normally at least a "user" and "password" property should be
included
Returns:
a Connection to the URL
Throws:
SQLException - if a database access error occurs
----

Assuming pgStatement is in fact a connection string, can't you:-

return pgStatement.getAutoCommit();

My 2 cents.

Robert

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message jenca 2018-11-14 15:59:07 Re: getAutocommit assertion error
Previous Message adrien ruffie 2018-11-14 14:08:19 RE: getAutocommit assertion error