package printSqlException;
import java.sql.SQLException;
import java.util.Calendar;
/*
* 类名:PintSqlException
* 类说明:通过打印方法,直接打印出SQLException中的警告及错误信息
* 作者:王康宇
* 日期:2007-03-15
*/
public class PrintSqlException {
SQLException se;
Calendar rn=Calendar.getInstance();
public PrintSqlException(SQLException se)
{
this.se=se;
}
public boolean printWarning() throws SQLException
{
Boolean rs=false;
if (se!=null)
{
rs=true;
System.out.println("/n**********Warning Start********"+rn.getTime()+"/n");
while(se!=null)
{
System.out.println("SQLState:"+se.getSQLState());
System.out.println("WarningMessage:"+se.getMessage());
System.out.println("Vendor:"+se.getErrorCode());
System.out.println("");
se=se.getNextException();
}
System.out.println("/n**********Warning End********"+rn.getTime()+"/n");
}
return rs;
}
public boolean printException()
{
boolean rs=false;
if (se!=null){
rs=true;
System.out.println("*******SQLException"+rn.getTime());
while (se!=null)
{
System.out.println("Message:"+se.getMessage());
se=se.getNextException();
}
}
return rs;
}
}
import java.sql.SQLException;
import java.util.Calendar;
/*
* 类名:PintSqlException
* 类说明:通过打印方法,直接打印出SQLException中的警告及错误信息
* 作者:王康宇
* 日期:2007-03-15
*/
public class PrintSqlException {
SQLException se;
Calendar rn=Calendar.getInstance();
public PrintSqlException(SQLException se)
{
this.se=se;
}
public boolean printWarning() throws SQLException
{
Boolean rs=false;
if (se!=null)
{
rs=true;
System.out.println("/n**********Warning Start********"+rn.getTime()+"/n");
while(se!=null)
{
System.out.println("SQLState:"+se.getSQLState());
System.out.println("WarningMessage:"+se.getMessage());
System.out.println("Vendor:"+se.getErrorCode());
System.out.println("");
se=se.getNextException();
}
System.out.println("/n**********Warning End********"+rn.getTime()+"/n");
}
return rs;
}
public boolean printException()
{
boolean rs=false;
if (se!=null){
rs=true;
System.out.println("*******SQLException"+rn.getTime());
while (se!=null)
{
System.out.println("Message:"+se.getMessage());
se=se.getNextException();
}
}
return rs;
}
}