```java
package cn.JDBC;
import java.io.FileReader;
import java.io.IOException;
import java.net.URL;
import java.sql.*;
import java.util.Properties;
public class JDBCSignIn {
public static boolean sign(String username,int pswd) throws SQLException {
Connection con = null;
PreparedStatement stmt;
ResultSet res = null;
try {
Class.forName("com.mysql.cj.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql:///db1","root","113277468");
System.out.println("连接驱动成功");
} catch (ClassNotFoundException | SQLException e) {
System.out.println("连接驱动失败");
}
String sql = "select * from signin where name= ? and pw = ?";
try {
stmt = con.prepareStatement(sql);
stmt.setString(1,username);
stmt.setInt(2,pswd);
res = stmt.executeQuery();
} catch (SQLException e) {
System.out.println("查询失败");
}
res.close();
stmt.close();
con.close();
return res.next();
}
}
![img](https://img-mid.csdnimg.cn/release/static/image/mid/ask/093619212736193.png "#left")
加了释放资源就出错
![img](https://img-mid.csdnimg.cn/release/static/image/mid/ask/248530312736158.png "#left")
把那三句删了就好。。。
是什么原因嘛,求教
```