I have the below code with which i am able to print the fullclassname,classname,methodname, at which error occured.
Also, I am able to print Line-Number but the Line-Number printed is the line at which the variable "LineNumber" is initialized.
How can i print the exact LineNumber and ColumnNumber in try block at which error occured?
try
{
SQL Query
}
catch(Exception e)
{
String fullClassName = Thread.currentThread().getStackTrace()[1].getClassName();
String className = fullClassName.substring(fullClassName.lastIndexOf(".") + 1);
String methodName = Thread.currentThread().getStackTrace()[1].getMethodName();
int lineNumber = Thread.currentThread().getStackTrace()[1].getLineNumber();
JOptionPane.showMessageDialog(null,fullClassName+"--"+className+"--"+methodName+"--"+lineNumber,"Error In Moving data from table1 to table2",JOptionPane.ERROR_MESSAGE);
}
Ouput:
IPM.Shifting--Shifting--ConfirmTransfer_BActionPerformed--1138
e.getStacktrace
instead ofThread.currentThread().getStackTrace
? – Outbound