How do I add text typed in a Java GUI to my database?

Using NetBeans, I've created a GUI, which has a 5 text boxes and an add/sumbit button. I've also created a database, which is on my Runtime Panel in Netbeans, and has a table with 5 columns. Once my GUI is running, I want the Add button to insert the information from each of the text boxes to the 5 columns in a row of the database. I haven't added any Event-> Action to my Add button yet.

I tried learning how to do this through the netbeans GUI JDBC tutorial, but it only showed a particular example, and didn't explain how this could be done in a differing situation. Can someone please tell me the code I'd need to access the database from the source code of my GUI?

thanks

[707 byte] By [karanmadhoka] at [2007-11-26 21:30:19]
# 1

Note that learning java and JDBC (and databases) at the same time is not a good idea.

Basically you do this.

1. Extract the values from the gui as strings

2. Open a JDBC connection.

3. Create a SQL insert statement.

4. Create a java string using 3.

5. Create a prepared statement using 4 (modifying the string appropriately)

6. Call executeUpdate (or whatever the JDBC method is called.)

7. Appropriately close the statement and connection.

8. Handle error conditions with appropriate try/catches for all of the above.

jschella at 2007-7-10 3:10:58 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2
Don't [url= http://forum.java.sun.com/thread.jspa?threadID=5147826&messageID=9551412#9551412]crosspost[/url]!!
bckrispia at 2007-7-10 3:10:58 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3
> Don't> [url= http://forum.java.sun.com/thread.jspa?threadID=51> 47826&messageID=9551412#9551412]crosspost[/url]!!Don't post like that its not nice ...
Paulvic@ACa at 2007-7-10 3:10:58 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 4
> Don't> [url= http://forum.java.sun.com/thread.jspa?threadID=51> 47826&messageID=9551412#9551412]crosspost[/url]!!Don't replay if you cannot answer the questions. Just read the threads...
Paulvic@ACa at 2007-7-10 3:10:58 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 5
> Just read the threads...Just bite my 醩s.
bckrispia at 2007-7-10 3:10:58 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...