What is IllegalStateException?

前端 未结 4 2381
借酒劲吻你
借酒劲吻你 2020-12-09 08:12

I am trying to use the following Fastload API

connection ... etc is perfect.


I know exactly where it fails

 ...........
 System.out.pr         


        
相关标签:
4条回答
  • 2020-12-09 08:40

    Usually, IllegalStateException is used to indicate that "a method has been invoked at an illegal or inappropriate time." However, this doesn't look like a particularly typical use of it.

    The code you've linked to shows that it can be thrown within that code at line 259 - but only after dumping a SQLException to standard output.

    We can't tell what's wrong just from that exception - and better code would have used the original SQLException as a "cause" exception (or just let the original exception propagate up the stack) - but you should be able to see more details on standard output. Look at that information, and you should be able to see what caused the exception, and fix it.

    0 讨论(0)
  • 2020-12-09 08:53
    package com.concepttimes.java;
    
    import java.util.ArrayList;
    import java.util.Iterator;
    import java.util.List;
    
    public class IllegalStateExceptionDemo {
    
        public static void main(String[] args) {
            // TODO Auto-generated method stub
            List al = new ArrayList();
            al.add("Sachin");
            al.add("Rahul");
            al.add("saurav");
            Iterator itr = al.iterator();  
            while (itr.hasNext()) {           
                itr.remove();
            }
        }
    }
    

    IllegalStateException signals that method has been invoked at the wrong time. In this below example, we can see that. remove() method is called at the same time element is being used in while loop.

    Please refer to below link for more details. http://www.elitmuszone.com/elitmus/illegalstateexception-in-java/

    0 讨论(0)
  • 2020-12-09 08:56

    Illegal State Exception is an Unchecked exception.

    It indicate that method has been invoked at wrong time.

    example:

    Thread t = new Thread();
    t.start();
    //
    //
    t.start();
    

    output:

    Runtime Excpetion: IllegalThreadStateException
    

    We cant start the Thread again, it will throw IllegalStateException.

    0 讨论(0)
  • 2020-12-09 08:59
    public class UserNotFoundException extends Exception {
        public UserNotFoundException(String message) {
            super(message)
    
    0 讨论(0)
提交回复
热议问题