• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to save to mysql on edit?  RSS feed

 
Jed Reisner
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have this file that I'm using to display users from a mysql database. I have a couple problems with it though. 1)When I open it, it opens the first window fine, but when I close it another random empty window opens. 2) I can't seem to get it to save changes to the database. What am I doing wrong?

 
Paul Clapham
Sheriff
Posts: 22375
42
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch, Jed!

It's possible that your SQL code is throwing exceptions, and that's why no updates are happening. Right now you just let the internal Swing code (the code which is calling the code you wrote) deal with those exceptions, and usually what it does is to just write the stack trace to the system console and carry on. However when you run a Swing app in the usual way, you can't see the console and so you can't tell whether exceptions are happening or not.

I'd suggest looking for that possibility to start with. Either deal with the exception in your code in some way (e.g. pop up a dialog box) or run the Swing app in an environment where you can see the console.

There might be a different reason why the updates aren't happening (there are several possibilities) but start with squashing the exceptions first.
 
Jed Reisner
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I thought I was printing all the errors to the console. Should I just add a System.out.println("It broke here") to a bunch of spots?
 
Paul Clapham
Sheriff
Posts: 22375
42
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually yes, you are writing the errors to the console. And can you see the console when you're running that code?
 
Jed Reisner
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, in netbeans I can usually see them. It doesn't seem like the update method is even firing.
 
Paul Clapham
Sheriff
Posts: 22375
42
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Netbeans? Then you should be able to step through the code with its debugger. Give that a try and see if the update method is called, and what happens if it is called.
 
Jed Reisner
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks like the second blank window is a nullpointerexception caused by the way I launch the window from a jmenu.

This is the code I have for that:

Not sure why it doesn't work or why it does it 2x. I copied the same thing I did with monthlyView which works fine.
 
Jed Reisner
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So my problem was doing things out of order which was causing nullPointerExceptions. Here is the working code if anyone ever has my same problem.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!