连接数据库(MySql)的时候, 我想设置连接超时限制,使用
DriverManager.setLoginTimeout(10);
connection = (Connection) DriverManager.getConnection(
"jdbc:mysql://" + ServiceIP + "/mydb", "user", "456");
DriverManager.setLoginTimeout(10);
connection = (Connection) DriverManager.getConnection(
"jdbc:mysql://" + ServiceIP + "/mydb", "user", "456");
完全没有作用,该怎么设置啊
建议不要使用jdbc,改用php搭建webservice,手机端用soap解码json的xml。
-------------------------------
引用 2 楼 a84939849 的回复:
那要是这样的话没法解决么
建议不要使用jdbc,改用php搭建webservice,手机端用soap解码json的xml。
那要是这样的话没法解决么
-------------------------------
jdbc:mysql://127.0.0.1:3066/test?connectTimeout=3000&socketTimeout=60000
好不容易找到的答案
好不容易找到的答案
HTTP请求时connectionRequestTimeout 、connectionTimeout、socketTimeout三个超时时间的含义
connectionRequestTimout:指从连接池获取连接的timeout
connetionTimeout:指客户端和服务器建立连接的timeout,
就是http请求的三个阶段,一:建立连接;二:数据传送;三,断开连接。超时后会ConnectionTimeOutException
socketTimeout:指客户端从服务器读取数据的timeout,超出后会抛出SocketTimeOutException