public static Connection getConnection(){
try {
return (Connection) DriverManager.getConnection(url,user,pwd);
} catch (Exception e) {
throw new RuntimeException("连接失败",e);
}
}
在这段代码中。若是将catch中换成e.printStackTrace();为什么会报没有返回值,但是这一种就是为什么就是对的?求解释!这段代码是连接数据库工具类的一部分!
try {
return (Connection) DriverManager.getConnection(url,user,pwd);
} catch (Exception e) {
throw new RuntimeException("连接失败",e);
}
}
在这段代码中。若是将catch中换成e.printStackTrace();为什么会报没有返回值,但是这一种就是为什么就是对的?求解释!这段代码是连接数据库工具类的一部分!









