Specifying TCP protocol in JDBC to mysql connection
How do you specify that the JDBC connection to mysql in the typical line
DriverManager.getConnection(u开发者_运维百科rl, username, password);
is via TCP?
Thanks
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.
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.
is this what you are looking for?
DriverManager.getConnection("jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF-8", username, password);
精彩评论