Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kdIqN-0008PV-3o for pgsql-jdbc@arkaria.postgresql.org; Thu, 12 Nov 2020 20:05:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kdIqM-0000l8-08 for pgsql-jdbc@arkaria.postgresql.org; Thu, 12 Nov 2020 20:05:18 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kdIqL-0000l0-Gb for pgsql-jdbc@lists.postgresql.org; Thu, 12 Nov 2020 20:05:17 +0000 Received: from mx1-es.rentec.com ([216.223.240.6]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kdIqH-0004T9-Da for pgsql-jdbc@lists.postgresql.org; Thu, 12 Nov 2020 20:05:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=rentec.com; i=@rentec.com; q=dns/txt; s=rtc081020; t=1605211513; x=1636747513; h=subject:to:references:from:message-id:date:mime-version: in-reply-to; bh=7d2BkypcUp+u4vz3EsOWxsp1dzXC7xZngRdQ/kOODwM=; b=JtZEH/YNO88vmVfJ0djU70DV+cGgCuTuTuokcqaTHNoneIsMh9oS1liM m+u0bkkmeRaMCow//Ex+yEep4p6aQmaP1JzS24hlNLr+Y8wTIDjTpielD 8N0LlR/2RYgEcfy9+Ca8M2LOuOd61WVIdA0woejUMPw3Hd/hCwkdUudo0 wI6j9OsU7cTAyPRhASzIJQEgWKs2xTEjzl4ULrtLGsl9ccjLL5s7iMu9Q /XF4Ypk0HOt2B5kFKqdRjAl4rkMJDVXWDz11Zc372VjQhhqhlqrMcXUL2 C9v5ZUdD9SbQTtxR2qAzSOaESb+y/d7r/GuJLSs94qHsQcqxKEngMDdwW w==; Subject: Re: first connection attempt always fails, subsequent always succeed To: Rob Sargent , David Gradwell , "pgsql-jdbc@lists.postgresql.org" References: <98039f46-ab40-2c79-7620-3fa35ecb9869@gmail.com> <83C25F63-72BD-484F-94F4-11D996E759D2@gradwell.com> <1239978e-d9bc-26d4-23f4-79009462cbae@gmail.com> From: Alan Stange Message-ID: Date: Thu, 12 Nov 2020 15:05:09 -0500 MIME-Version: 1.0 In-Reply-To: <1239978e-d9bc-26d4-23f4-79009462cbae@gmail.com> Content-Type: multipart/alternative; boundary="------------DD0F1D4A5293059F492B7BBB" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------DD0F1D4A5293059F492B7BBB Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit On 11/12/20 2:31 PM, Rob Sargent wrote: > > > On 11/12/20 12:11 PM, David Gradwell wrote: >> >> Rob, >> >>   >> >> If this is obvious apologies, but have you explicitly included an >> appropriate JDBC driver in your .war build ?  >> https://jdbc.postgresql.org/download.html >>    I am currently fighting >> issues with MacOS apparently not allowing connections to be made >> (timeout or host not found) and have reverted to a 9.3 build for testing. >> >>   >> >> Are you using NetBeans  as your IDE ? >> >>   >> >> David Gradwell >> >>   >> >> *From: *Rob Sargent >> *Date: *Thursday, 12 November 2020 at 18:59 >> *To: *"pgsql-jdbc@lists.postgresql.org" >> *Subject: *first connection attempt always fails, subsequent always >> succeed >> >>   >> >> This is an embedded tomcat application, not full-blown apache >> server.  Works great when it does...  I haven't wired in a connection >> supplier yet since (for now) there are few clients and they do two >> reads and one write, all very large. >> >> java: >> >> java -version >> openjdk version "11.0.9" 2020-10-20 >> OpenJDK Runtime Environment (build 11.0.9+11-Ubuntu-0ubuntu1.20.04) >> OpenJDK 64-Bit Server VM (build 11.0.9+11-Ubuntu-0ubuntu1.20.04, >> mixed mode, sharing) >> >> tomcat:  >> >> version 9.0.39 >> >> poostgres: >> >> PostgreSQL 12.4 >> >> This is the servlet's connection code: >> >> String templateUrl = >> System./getProperty/("SGSSVR_databaseConnection", >> "jdbc:postgresql://%s/%s"); ///host(with :port) / dbname/ >> >> String fullurl = String./format/(templateUrl, dbhost, dbname);  >> //will add port to this next >> >> conn = DriverManager./getConnection/(fullurl, dbrole, magicPassword); >> >> dsl = DSL./using/(conn, SQLDialect./POSTGRES/); >> >> which generates this stack trace, showing what looks to me like a >> good url (and which works later). >> >> java.sql.SQLException: No suitable driver found for >> jdbc:postgresql://localhost/version4007 >>     at >> java.sql/java.sql.DriverManager.getConnection(DriverManager.java:702) >> > thinking these forums like bottom posting > > From my war file (which I explode) > > WEB-INF/lib/postgresql-42.2.18.jar > > I get the same behaviour running from within IntelliJ and from > gradle/command-line, on ubuntu 20.0 > Do you have a call Class.forName("org.postgresql.Driver"); in the code to load the postgresql driver into the application? Alan --------------DD0F1D4A5293059F492B7BBB Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit
On 11/12/20 2:31 PM, Rob Sargent wrote:


On 11/12/20 12:11 PM, David Gradwell wrote:

Rob,

 

If this is obvious apologies, but have you explicitly included an appropriate JDBC driver in your .war build ?  https://jdbc.postgresql.org/download.html   I am currently fighting issues with MacOS apparently not allowing connections to be made (timeout or host not found) and have reverted to a 9.3 build for testing.

 

Are you using NetBeans  as your IDE ?

 

David Gradwell

 

From: Rob Sargent <robjsargent@gmail.com>
Date: Thursday, 12 November 2020 at 18:59
To: "pgsql-jdbc@lists.postgresql.org" <pgsql-jdbc@lists.postgresql.org>
Subject: first connection attempt always fails, subsequent always succeed

 

This is an embedded tomcat application, not full-blown apache server.  Works great when it does...  I haven't wired in a connection supplier yet since (for now) there are few clients and they do two reads and one write, all very large.

java:

java -version
openjdk version "11.0.9" 2020-10-20
OpenJDK Runtime Environment (build 11.0.9+11-Ubuntu-0ubuntu1.20.04)
OpenJDK 64-Bit Server VM (build 11.0.9+11-Ubuntu-0ubuntu1.20.04, mixed mode, sharing)

tomcat: 

version 9.0.39

poostgres:

PostgreSQL 12.4

This is the servlet's connection code:

String templateUrl = System.getProperty("SGSSVR_databaseConnection", "jdbc:postgresql://%s/%s"); //host(with :port) / dbname
String fullurl = String.format(templateUrl, dbhost, dbname);  //will add port to this next
conn = DriverManager.getConnection(fullurl, dbrole, magicPassword);
dsl = DSL.using(conn, SQLDialect.POSTGRES);

which generates this stack trace, showing what looks to me like a good url (and which works later).

java.sql.SQLException: No suitable driver found for jdbc:postgresql://localhost/version4007
    at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:702)

thinking these forums like bottom posting

From my war file (which I explode)

WEB-INF/lib/postgresql-42.2.18.jar

I get the same behaviour running from within IntelliJ and from gradle/command-line, on ubuntu 20.0


Do you have a call

Class.forName("org.postgresql.Driver");

in the code to load the postgresql driver into the application?

Alan


--------------DD0F1D4A5293059F492B7BBB--