Java SE 7 异常处理
publicstaticvoid main(String[] args) {
try{
XXX()xx = newXXXX();
xx.xxx();
}catch(ParseException exception){
}catch(IOException exception){
}catch(ProduceExceptionexception){
}
}
publicstaticvoid main(String[] args) {
try{
}catch(Exception exception){
}
}
publicstaticvoid main(String[] args) {
try{
}catch(ParseException | IOException exception){
}
}
publicstaticvoid main(String[] args) {
try{
createTest();
}catch(IOException exception){
System.err.println(exception.getMessage());
}
}
publicstaticvoid createTest() throws Exception{
try{
Test4 test = new Test4();
test.notifyAll();
}catch(Exception e){
throw e;
}
}
publicstaticvoid main(String[] args) {
try{
createTest();
}catch(RuntimeException exception){
System.err.println(exception.getCause().getMessage());
}
}
publicstaticvoid createTest() throws Exception{
try{
thrownew IOException("Error");
}catch(IOException e){
thrownew RuntimeException(exception);
}
}
publicstaticvoid main(String[] args) {
try{
createTest();
}catch(IOException exception){
System.err.println(exception.getCause().getMessage());
}
}
publicstaticvoid createTest() throws Exception{
try{
thrownew IOException("Error");
}catch(IOException e){
thrownew RuntimeException(exception);
}
}
publicstaticvoid main(String[] args) {
Connection conn = null;
String sql;
String url = "jdbc:mysql://XXXXX:XXXXX/XXXXX?" + "user=root&password=root&useUnicode=true&characterEncoding=GBK";
try {
Class.forName("com.mysql.jdbc.Driver");//
conn = DriverManager.getConnection(url,"XXXX","XXXX");
Statement stmt = conn.createStatement();
for(inti=0;i<10000;i++){
sql = "INSERT INTO bop_libra_00.bm_application_0093 "
+ "(application_id) "
+ "VALUES "
+ "(10228"+i+"0605)";
intresult = stmt.executeUpdate(sql);
System.out.println(result);
}
} catch (SQLException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
} finally {
try {
e.printStackTrace();
}
publicstaticvoid main(String[] args) {
Connection conn = null;
String sql;
String url = "jdbc:mysql://XXXXX:XXXXX/XXXXX?" + "user=root&password=root&useUnicode=true&characterEncoding=GBK";
try(conn = DriverManager.getConnection(url,"XXXX","XXXX")){
Class.forName("com.mysql.jdbc.Driver");//
Statement stmt = conn.createStatement();
for(inti=0;i<10000;i++){
sql = "INSERT INTO bop_libra_00.bm_application_0093 "
+ "(application_id) "
+ "VALUES "
+ "(10228"+i+"0605)";
intresult = stmt.executeUpdate(sql);
System.out.println(result);
}
} catch(SQLException | ClassNotFoundException e) {
e.printStackTrace();
}
}
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。