简体   繁体   English

在JDBC中指定TCP协议到mysql连接

[英]Specifying TCP protocol in JDBC to mysql connection

How do you specify that the JDBC connection to mysql in the typical line 如何在典型行中指定与mysql的JDBC连接

DriverManager.getConnection(url, username, password);

is via TCP? 通过TCP?

Thanks 谢谢

Just use a JDBC type 3 or 4 driver. 只需使用JDBC类型3或4驱动程序。

Even more, as far as I know, all MySQL JDBC drivers are type 3/4 already. 更进一步,据我所知,所有MySQL JDBC驱动程序都已经是3/4型。

As far as I know, TCP will be the underlying protocol despite the nature of the driver used. 据我所知,尽管使用了驱动程序的性质,TCP仍将是底层协议。 Unlike Derby or HSQLDB, MySQL does not support (at the time of writing this) any form of databases that operate in an embedded mode. 与Derby或HSQLDB不同,MySQL不支持(在编写本文时)任何形式的以嵌入模式运行的数据库。

All connections made to the database for the purpose of executing SQL statements, made by the driver happen to be TCP connections. 为了执行SQL语句而对数据库进行的所有连接都是由TCP连接构成的。

这是你想要的?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM