public static void main(String[] args) throws Throwable { /* 1、未运行程序前,到cmd控制台查看netstat是否有数据库连接 C:\>netstat -np TCP | grep 1521 */ oracle.jdbc.driver.OracleDriver.class.newInstance(); Connection con = DriverManager.getConnection( "jdbc:oracle:thin:@192.168.10.10:1521:orcl", "h2do", "h2do"); System.in.read(); /* 2、io阻塞,到cmd控制台查看netstat C:\>netstat -np TCP | grep 1521 TCP 192.168.10.192:63198 192.168.10.10:1521 ESTABLISHED */ con.close(); /* 3、程序回车关闭数据库连接,到cmd控制台查看netstat C:\>netstat -np TCP | grep 1521 TCP 192.168.10.192:63198 192.168.10.10:1521 TIME_WAIT 关闭 socket连接时,主动关闭端进入TIME_WAIT状态,被动关闭端进入CLOSED状态。 */ }
时间: 2024-10-26 07:37:56