Using jdk1.6, there SQLexception(String s) is defined. But in my workspace it showing that SQLexception(String s) is undefined, please help.
Asked
Active
Viewed 749 times
-1
-
1Did you import it? – shmosel Nov 22 '17 at 07:34
-
2First, put the code and not screenshot. Second, check JRE version in your eclipse. Right click on project, properties and the Java. It's should JRE 1.6 or above – voucher_wolves Nov 22 '17 at 07:36
-
1Don't throw a new one. Throw the one you caught. – user207421 Nov 22 '17 at 07:37
-
yes, i already have imported java.sql.SQLException. – nitincse Nov 22 '17 at 07:38
-
@yashpandey:it's jre1.6.0_45 – nitincse Nov 22 '17 at 07:39
-
@EJP and don't print the stack trace of the current one. This can make it look like you have multiple exceptions if you print it somewhere else as well. – Andy Turner Nov 22 '17 at 07:39
-
1In other words don't catch it at all. Catch-and-throw is an anti pattern. @AndyTurner – user207421 Nov 22 '17 at 07:40
-
May be closing the connection to early. Just a guess. – SedJ601 Nov 22 '17 at 07:47
-
@EJP In this case, this is not the case. No such antipattern. But you can specify another rollback option per transaction. – mr mcwolf Nov 22 '17 at 07:48
-
Try saving your file and refreshing your project – Praveen Nov 22 '17 at 07:50
-
Please post a [mcve] – Mark Rotteveel Nov 25 '17 at 08:54
1 Answers
-1
this is because sqlexception is a checked exception , need to be wrapped with a try catch. if u are going to throw it again in the try catch it is better to throw it in the method. or throw a runtimeexception

Juan Pablo
- 304
- 3
- 8