被楼上抢了先,呵呵
if (conn==null) {
}
if (conn==null) {
}
解决方案 »
- 请教增强for循环中的一个问题。
- java如何限制从控制台输入的数据类型?
- 请各路高手帮忙看看这个问题
- 操作符“+”的定义,他是否是new了一个新的字符串?
- 编写一个用来创建一个ArrayList对象的程序,但是不明确导入java.util.*
- 一个对象如何得知另一对象处理了某个事件..
- 简单问题,关于继承
- 如果JMenu下面没有JMenuItem的话,应该怎么处理
- 用ByteBuffer写文件的性能问题
- socket使用两个线程分别收发,收到结束标识怎么结束发线程的流
- 请问Java中如何调用dll动态连接库?
- 请问大家: 在DOS下运行c:\>javac HelloWorld.java 为什么会出现"cannot read HelloWorld.java"的错误?
使用 conn
}catch{
出错抓取
}
使用 conn
}catch{
出错抓取 // 出错不一定就是断连,
}
if (conn==null) {
}
我测试时,这样好象判断不出来?
}java.sql
Interface ConnectionisClosed
public boolean isClosed()
throws SQLExceptionRetrieves whether this Connection object has been closed. A connection is closed if the method close has been called on it or if certain fatal errors have occurred. This method is guaranteed to return true only when it is called after the method Connection.close has been called.
This method generally cannot be called to determine whether a connection to a database is valid or invalid. A typical client can determine that a connection is invalid by catching any exceptions that might be thrown when an operation is attempted.
Returns:
true if this Connection object is closed; false if it is still open
Throws:
SQLException - if a database access error occurs