Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is IllegalStateException?

I am trying to use the following Fastload API

connection ... etc is perfect.


I know exactly where it fails

 ...........  System.out.println(" Streaming " + dataFile);  pstmtFld.setAsciiStream(1, dataStream, -1); // This line fails  System.out.println("check the above line"); // This does not go to console  ........... 

Exception is

Exception in thread "main" java.lang.IllegalStateException: Sample failed.

[ODBC Teradata Driver] Invalid precision: cbColDef value out of range


Here is my table that I am trying to upload. It is a .csv format and when I open it via notepad it look like this

1,9,Win 2,9,Winc 3,9,Wi 

Why do I get this exception? How can I improve it? As far as I understand the problem is pstmtFld.setAsciiStream(1, dataStream, -1); does not accept the dataset somehow and throw an exception

like image 827
Borat Sagddiev Avatar asked Nov 23 '13 23:11

Borat Sagddiev


People also ask

Why does Java Lang IllegalStateException occur?

Indicates that the app has exceeded a limit set by the System. Signals that a method has been invoked at an illegal or inappropriate time. In other words, the Java environment or Java application is not in an appropriate state for the requested operation.

How do you throw an illegal state exception?

This exception is thrown when you call a method at illegal or inappropriate time an IlleagalStateException is generated. For example, the remove() method of the ArrayList class removes the last element after calling the next() or previous methods.

What is an IllegalArgumentException in Java?

IllegalArgumentException is a Java exception indicating that a method has received an argument that is invalid or inappropriate for this method's purposes.


1 Answers

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.

like image 196
Jon Skeet Avatar answered Sep 21 '22 05:09

Jon Skeet