algorithmicCoder
algorithmicCoder

Reputation: 6789

Specifying TCP protocol in JDBC to mysql connection

How do you specify that the JDBC connection to mysql in the typical line

DriverManager.getConnection(url, username, password);

is via TCP?

Thanks

Upvotes: 1

Views: 5870

Answers (3)

sanssucre
sanssucre

Reputation: 17

is this what you are looking for?

DriverManager.getConnection("jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF-8", username, password);

Upvotes: -1

Vineet Reynolds
Vineet Reynolds

Reputation: 76719

As far as I know, TCP will be the underlying protocol despite the nature of the driver used. Unlike Derby or HSQLDB, MySQL does not support (at the time of writing this) any form of databases that operate in an embedded mode.

All connections made to the database for the purpose of executing SQL statements, made by the driver happen to be TCP connections.

Upvotes: 2

BalusC
BalusC

Reputation: 1109172

Just use a JDBC type 3 or 4 driver.

Even more, as far as I know, all MySQL JDBC drivers are type 3/4 already.

Upvotes: 2

Related Questions