• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

SQLException

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.


 
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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]
 
ruba sampath
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?


 
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Nicola Garofalo
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please do not consider my answer.
My mistake.

 
Ranch Hand
Posts: 544
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI

Issue fixed. Thanks a lot for your valuable comments.

Regards
Ruba Sam
 
Listen. That's my theme music. That's how I know I'm a super hero. That, and this tiny ad told me:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic