3 messages in com.mysql.lists.javaRe: Dependent SQL calls using the JDBC| From | Sent On | Attachments |
|---|---|---|
| Stuart G. Poss | 06 Jun 2000 16:22 | |
| Cris Perdue | 06 Jun 2000 21:40 | |
| LEBLANC, CLAUDE | 07 Jun 2000 05:49 |
| Subject: | Re: Dependent SQL calls using the JDBC![]() |
|---|---|
| From: | Cris Perdue (cr...@perdues.com) |
| Date: | 06/06/2000 09:40:31 PM |
| List: | com.mysql.lists.java |
I have a simple servlet (using the org.gjt.mm.mysql driver) that creates a flat html table displaying many the many fields a mySQL table. However, some users tell me that the size of the table creates browser viewing problems. Consequently, I am interested in displaying an abbreviated table that permits the values of a key field to display the remaining data fields for records with that value only, essentially "drilling down" into the table.
In effect, I want to create a second HTML table (separate page) that effectively generates series of potentially "dependent" servlets that use the value of the hyperlinked field to populate the value for a WHERE clause. That is, the first call would be SELECT FIELD1, FIELD2 FROM TABLEX; and the second call would then be generated from hyperlinks within the second displayed table of the form SELECT FIELD3, FIELD4, ... FIELD50 FROM TABLEX WHERE FIELD1="value for that row of initial html table".
How can I create the second HTML table without actually creating multiple copies of the servlet code for each and every unique value of FIELD1?
I guess that this is another way of asking how can I use the JDBC to evoke mySQL to obtain (construct) the equivalent of a cgi call to a URL with appended ?name="value" parameters.
Has anyone done this and would you be willing to share some code?
JDBC is just a way of accessing databases. It is unrelated to CGI, and can be used in applications that have nothing to do with the Web or HTML or HTTP.
Servlets and JSP pages *are* like CGI scripts, but written in Java and generally tend to perform better. Learn about Servlets and JSP. Then you will be able to write "the equivalent of a CGI call to a url with appended ?name=value parameters". When you have obtained the parameters you want, pass them in to the database to get the information you want.
Good luck, -Cris




