直接在 catch(){} 块里:
catch(SAXParseException sax){
System.out.println("TestCatch:readXml"+sax.getMessage() );
}
不继续抛出异常,试试看怎么样
catch(SAXParseException sax){
System.out.println("TestCatch:readXml"+sax.getMessage() );
}
不继续抛出异常,试试看怎么样
打个比方
你try catch()整数转换的时候,如果不做整数转换,那么就会报这个错。
就是
try
{}
catch(NumberFormatException)
{}//报错
和
try
{
Integer.parseInteger("0");
}
catch(NumberFormatException)
{}
的区别。
这个异常我不捕捉的时候,假如实际上有异常发生,WEBLOGIC控制台下还是会产生SAXParseException,现在的情况是我想自己捕捉到它,并做相应处理。
任务是这样的:就是解析个XML文件(里面为合同的数据库记录数据),把它解析出来插入到数据库就可以了。插入之前我是先把XML数据解析到VO里面,再插的。
那个报错的意思是你try{}块中并没有任何一个方法会跑出这个例外
如果确定位置正确,将
catch(SAXParseException sax)
改为:
catch(Exception sax){
如:
java.sql.ResultSet
String getString(String columnName)
throws SQLException
Retrieves the value of the designated column in the current row of this ResultSet object as a String in the Java programming language.
Parameters:
columnName - the SQL name of the column
Returns:
the column value; if the value is SQL NULL, the value returned is null
Throws:
SQLException - if a database access error occurs