• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Weird, why is some previous version of a class running

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have this class named DataBaseDemo.java and I had it originally set up to use MySQL but then I altered it to use ORACLE
But I only half way did the change and did a save and click the run button.
So I was struck dumb when it did run. Then I looked at the output and I could tell that it was behaving as if I never made any changes.
So why might that be?
Weird-JAVA-and-DB-Connection-PM.jpg
[Thumbnail for Weird-JAVA-and-DB-Connection-PM.jpg]
 
Rod Hittle
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just adding the fact that I am using Eclipse to run the class.
 
Marshal
Posts: 8856
637
Mac OS X VI Editor BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Folks in JavaRanch prefer to see actual code posted rather than pictures. So, please do post actual code here, and do not forget to UseCodeTags (<- link). If you're not familiar how to use them, please check that tutorial page in the link I gave you.
 
Rod Hittle
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Rod Hittle
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And as I wrote there is no way in the world that this is the code that is being executed when I click the run button. I am stumped as to why it is running code done before extensive change.
 
Liutauras Vilda
Marshal
Posts: 8856
637
Mac OS X VI Editor BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One thing, line 23 and line 24:
could be changed to:


So, print out CUST_LAST_NAME and see if you get what you expect.
By the way, why variable doesn't fit to Java naming convention?
Only constants suppose to be named in Upper cases. In your case it is not a constant.
 
Liutauras Vilda
Marshal
Posts: 8856
637
Mac OS X VI Editor BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check also differences between "prepareStatement method of PreparedStatement class" vs "createStatement method of Statement class".
Usually first method is preferred over the latter one.
 
Rod Hittle
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Liutauras, but that is not the issue. The issue is that the code you and I see here is NOT the code that is being executed when I click the execute button. I can't understand how that can be. I changed much of the code , did a save. But somehow it is like it has an old copy of the code and is running that.
 
Ranch Hand
Posts: 624
9
BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Never faced this kind of issue in eclipse.
Can you just delete the generated .class file from disk and try again.
 
Liutauras Vilda
Marshal
Posts: 8856
637
Mac OS X VI Editor BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rod Hittle wrote:Thanks Liutauras, but that is not the issue. The issue is that the code you and I see here is NOT the code that is being executed when I click the execute button. I can't understand how that can be. I changed much of the code , did a save. But somehow it is like it has an old copy of the code and is running that.


Well, I wouldn't like to believe.

Put away IDE. As Tapas said, delete .class file, compile again from commander/terminal and execute your program from the same location.
Then tell us what you get.
 
Rod Hittle
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I did "Remove the .classpath entry from that tab"


The good news is that when I went back to my project "VC" and then went down to any of the packages and opened them up and selected one of the classes and then ran it and it worked! So now I don't have to try to recreate anything.

classpath-remove.jpg
[Thumbnail for classpath-remove.jpg]
 
Rod Hittle
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not sure why the classpath file was ever there to begin with but removing it did the trick as I said.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic