I am trying to implement a sql statement into my eclipse code that creates/recreates a table when the 'intialize database' button is clicked. I believe my create statement is correct, but I am receiving no response when the button is clicked. Is there something wrong with my statement? Or am I missing something else in the code?
I would suggest extracting the database code from that program and writing a small program which does nothing but run the database code. It's a lot easier to test code which isn't encumbered by a lot of other unrelated code.
You could also try using your same DDL command directly with the mysql command-line interface and see what happens there.
Also, visually inspect the command to confirm everything looks correct.
posted 1 month ago
I now have the database create statements by themselves and linked to the interface with the button. One more question, since the tables are created once the button is pressed every button press thereafter throws the error "table already exists" is there a way to do away with this or have the table be recreated every time the button is pressed?
In case you need to see my code for the database now
After you've implemented what Dave Tolls suggested, try cleaning up the code.
* Try commenting out line 18, (Class.forName...) I'd be surprised if you need it. Now you don't need to catch Exception.
* Separate the one giant try/catch block into two blocks, one that catches the connection errors and one that catches the statement errors.
* Now you can use try with resources instead of the finally blocks.
* Format your code correctly. Follow this link for HowToFormatCode.
All things are lawful, but not all things are profitable.
The fastest and most reliable components of any system are those that are not there. Tiny ad: