A Quick Look at JDBC and MySQL

After completing the setup instructions in Appendix B,“Getting and Installing MySQL and JDBC,” you should have a working MySQL and JDBC installation in place. Now let's create a small table in MySQL and try getting to it from JSP. Rather than create the table directly by typing to the command line, you'll put the commands in a file and run it so that you can fix things more easily if you make a typo. You'll put all of your SQL scripts in their own directory under CARTAPP to keep them organized. (See Listing 1.8.)

Listing 1.8. employees.sql
 drop table IF EXISTS employees; create table employees ( lname_txt char(50), fname_txt char(50), employee_num integer primary key, address1_txt char(120), address2_txt char(120), ...

Get MySQL™ and JSP™ Web Applications: Data-Driven Programming Using Tomcat and MySQL now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.