Skip to content

Connection Validation Behavior in Presto JDBC Driver , Is Lazy Validation Intentional? #26596

@imsayari404

Description

@imsayari404

Discussed in https://github.com/orgs/prestodb/discussions/26569

Originally posted by imsayari404 November 10, 2025
The Presto JDBC driver uses lazy connection validation : getConnection() succeeds without performing network validation, and actual connectivity is only verified during the first metadata or query operation. This behaviour differs from other JDBC drivers like MySQL, which perform eager validation at getConnection() time.

Testing & Findings
I tested both Presto JDBC driver (v0.295) and MySQL Connector/J (v9.2.0) with wrong and correct ports to compare their validation behaviour.

presto-jdbc :

// Wrong port: 843 instead of 443
String wrongPortUrl = "jdbc:presto://host.example.com:843/?SSL=true";
String correctPortUrl = "jdbc:presto://host.example.com:443/?SSL=true";

MySQL JDBC:

// Wrong port: 32662 instead of 32661
String wrongPortUrl = "jdbc:mysql://host.example.com:32662/db?useSSL=true";
String correctPortUrl = "jdbc:mysql://host.example.com:32661/db?useSSL=true";

Results

Presto JDBC Driver (Lazy Validation):

========== WRONG PORT ==========
✓ getConnection() SUCCEEDED in 432ms
✓ getMetaData() SUCCEEDED in 0ms
✗ getDatabaseProductVersion() FAILED
   Error: java.net.ConnectException: Connection refused

========== CORRECT PORT ==========
✓ getConnection() SUCCEEDED in 3ms
✓ getMetaData() SUCCEEDED in 0ms
✗ getDatabaseProductVersion() FAILED  
   Error: SSLHandshakeException (certificate issue - testing from external client)

MySQL JDBC Driver (Eager Validation):

========== WRONG PORT ==========
✗ getConnection() FAILED immediately
   Error: CommunicationsException: Communications link failure
   
========== CORRECT PORT ==========
✓ getConnection() SUCCEEDED in 3719ms
✓ getMetaData() SUCCEEDED in 1ms
✓ getDatabaseProductVersion() SUCCEEDED in 0ms

Observation :
Presto: getConnection() and getMetaData() succeed for both valid and invalid ports. Network validation only occurs when calling getDatabaseProductVersion() or executing queries.
MySQL: getConnection() fails immediately with wrong port. Connection validation happens during the getConnection() call itself.

Is Lazy Validation Intentional for Presto JDBC Driver?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions