• 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
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

executeQuery problem

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


i am using netbean idd e every thing fine but when I use executeQuery nothing goes wrong build is success but I can not find my desired results
image_2021-09-10_211915.png
[Thumbnail for image_2021-09-10_211915.png]
 
Saloon Keeper
Posts: 8449
71
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are dealing with two classes named "Statement" and you're using the wrong one. Try java.sql.Statement.
 
Carey Brown
Saloon Keeper
Posts: 8449
71
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It would be much better if you'd cut and paste the text (both code and error messages) into a post rather than taking a screen snapshot. I could only see clearly on my 43" monitor.
 
Bartender
Posts: 1314
39
IBM DB2 Netbeans IDE Spring Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The first thing you have to look at when something goes wrong, is the stack trace of the exception you get. In this case, you have imported the wrong Statement class (java.beans.Statement instead of , presumably, java.sql.Statement or some concrete implementation).
Fix it - Ide should assist you with some feature like 'Fix Imports'.
 
obaid abbassi
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks problem solved!








 
Marshal
Posts: 73760
332
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And what was the solution?
 
Marshal
Posts: 22409
121
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That cast should have been a warning that you were using the wrong Statement import in the first place. With the right import, the cast would be unnecessary.

The only reason the cast is allowed by the compiler is because java.beans.Statement is a non-final class and java.sql.Statement is an interface. If the former were final or the latter be a class, the cast would have given a compiler error.
 
Do the next thing next. That’s a pretty good rule. Read the tiny ad, that’s a pretty good rule, too.
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic