This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes SQLException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "SQLException" Watch "SQLException" New topic
Author

SQLException

ruba sampath
Greenhorn

Joined: Jun 17, 2011
Posts: 28
Hi,,

I m getting error like "The constructor SQLException(SQLException) is undefined ".

i m using code like this:

1 catch (SQLException e) {
2 throw new SQLException(e);
3 }

There is a error at line 2 says "The constructor SQLException(SQLException) is undefined"

Kindly please anyone help on this.


Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3817

Can you provide the related code (including imports) you use here? Generally if you have imported java.sql.SQLException this should work. But it’s hard to tell for sure without looking at your code. Please read TellTheDetails.

[EDIT]Modified the incorrect package used as java.sql instead java.lang[/EDIT]


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
ruba sampath
Greenhorn

Joined: Jun 17, 2011
Posts: 28
exception
javax.servlet.ServletException: Servlet execution threw an exception
filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:121)


root cause


java.lang.Error: Unresolved compilation problem:
The constructor SQLException(SQLException) is undefined

Please provide me a solution how to resolve it?


Nicola Garofalo
Ranch Hand

Joined: Apr 10, 2010
Posts: 308
Take a look at SQLException API. Can you find a constructor for SQLException class that takes an SQLException instance as a parameter?
Anyway, why would you catch an SQLException to throw another SQLException after one line?


Bye,
Nicola
Nicola Garofalo
Ranch Hand

Joined: Apr 10, 2010
Posts: 308
Please do not consider my answer.
My mistake.

amit punekar
Ranch Hand

Joined: May 14, 2004
Posts: 511
Hello,
The Constructor that you are using is available only from Java 1.6.
I suppose you are using version which is lower than 1.6. That is the reason its not able to compile.

Moreover if you just want re-throw the SQLException then you may not need to create a new instance of SQLException. Instead you can use "e" e.g throw e;

Regards,
Amit
ruba sampath
Greenhorn

Joined: Jun 17, 2011
Posts: 28
HI

Issue fixed. Thanks a lot for your valuable comments.

Regards
Ruba Sam
 
 
subject: SQLException
 
Similar Threads
Undefined error
MINDQ EXAM- Q29, Q38, Q50(Please answer)
How to disable all form elements
not able to call my header file
can't get value from another class