public static Connection getConnection(){
try {
return datasource.getConnection();
} catch (SQLException e) {
//这里得用运行时异常。不然就会报没有return的错误
System.out.println(e);
throw new RuntimeException(e);//一定要加上这句,才能有用,暂时不知道为什么
}
}
有返回值的函数,如果包含try/catch块,经常会出现没有return的错误
原文:http://www.cnblogs.com/chohyee/p/7066363.html