Homepage¦¦Homepage of Work¦¦Exercises with JSP-MySQL

Comments on the JSP-MySQL Exercises

The Exercises

    When I was doing these exercises, I had in mind to create a means through which a course registration could be manipulated. To register into a course, students should fill in some kind of forms and then see whether they have done it. Besides teachers can also see who have registered into the courses.

Problems Encountered and Solutions

    First of all, I should create the table. I followed the materials and still got puzzled. I had no idea where to create the table and where and how to show it. It was Sylevie who showed me step by step how to do it all. The steps are:

  1. Create a table, e.g. creerTable.txt
  2. Put it into "home"
  3. In telnet: connect to tecfasun5.unige.ch

  4. login
    cd mysql(the directory where you put the file, here creerTable.txt)
    mysql -u staf2x -p staf2x < creerTable.txt
    password staf777
    mysql -u staf2x -p staf2x
    password staf777

    mysql> use staf2x;
    Database changed
                    show tables;
                    describe name_of_the_table;
                    select*from name_of_the_table;

    Once the table was created, a JSP or servlet should be created to call data from it. I followed the examples and found it was better for me to create a JSP which is easier. Besides I don't know how to put a servlet file into the right part of the server. Again I did a lot of copy and paste work. I found it is not a bad way in learning programming. We take examples and then change it and add our own contents. But we should understand the basic things to put in the right content and then to make it work. Little by little we understand it all. That's what happened to me in doing all the exercises.

    One problem I met with table is that each time I executed the program, there was always a message as: Error during Qurry: Unexpected Exception: java.sql.SQLException message given: General Error: Column count doesn't match value count at row 1.  It puzzled me two days. In the end, when I read again the code of the example, I found that in the table, 'id' is automatic, it does not count as a value. Thus there were three colunms in the table I created instead of four as I thought. So I added another colunm and it works now.

    Another problem I met is that I intended to put the last three into the same file. I succeeded but it appeared not so well. There was always some sort of feedback  before any data were inserted. So I divided it into three in the order of : insert data-----show feedback-----show table. It looks better in this way.

Sun April 2000