You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Maarten van Heiningen <He...@Phonehouse.nl> on 2002/07/03 15:41:47 UTC
updating records in a Mysql db using jsp.
Hi,
I am using a mysql db with jdbc on a win2000 server with Tomcat. I wonder
how I can update or delete items in a row or delete a complete row. I can
select the specific data in the table and put it on the webpage, but I also
want to edit this selected item.
any sugestions?
Maarten
sample code:
<%@ taglib uri="http://jakarta.apache.org/taglibs/dbtags" prefix="sql" %>
<%-- open a database connection --%>
<sql:connection id="conn1">
<sql:url>jdbc:mysql://localhost/producten</sql:url>
<sql:driver>org.gjt.mm.mysql.Driver</sql:driver>
</sql:connection>
<%-- open a database query --%>
<form name='form'>
<table>
<sql:statement id="stmt1" conn="conn1">
<sql:query>
SELECT manuf, type, prijs FROM mobile WHERE
manuf='<%=request.getParameter("manuf") %>' AND
type='<%=request.getParameter("type") %>'
order by 1
</sql:query>
<%-- loop through the rows of your query --%>
<sql:resultSet id="rset2">
<tr>
<td><sql:getColumn position='1'/></td>
<td><sql:getColumn position='2'/></td>
<td><input type="text" name="price" size="20" value="<sql:getColumn
position='3'/>"/></td>
<td><input type="button" name="submit" value="update" onClick="
UPDATE mobile SET prijs = ' + price + ' WHERE manuf = ' + manuf + '
AND type = ' + type + '"
/></td>
</tr>
</sql:resultSet>
</sql:statement>
</table>
</form>
<table width='100%'>
<hr height='2'/>
</table>
<%-- close a database connection --%>
<sql:closeConnection conn="conn1"/>
Disclaimer
This communication together with any attachments transmitted with it ('this E-mail') is intended only for the use of the addressee and may contain information which is privileged and confidential. If the reader of this E-mail is not the intended recipient or the employee or agent responsible for delivering it to the intended recipient you are notified that any use of this E-mail is prohibited. Addressees should ensure this E-mail is checked for viruses. The Carphone Warehouse Group PLC makes no representations as regards the absence of viruses in this E-mail. If you have received this E-mail in error please notify our ISe Response Team immediately by telephone on + 44 (0)20 8896 5828 or via E-mail at postmaster@cpw.co.uk Please then immediately destroy this E-mail and any copies of it.
Please feel free to visit our website:
UK
http://www.carphonewarehouse.com
Group
http://www.phonehouse.com
AW: updating records in a Mysql db using jsp.
Posted by "Power-Netz (Schwarz)" <sc...@power-netz.de>.
>
> Hi,
>
> I am using a mysql db with jdbc on a win2000 server with Tomcat. I wonder
> how I can update or delete items in a row or delete a complete row. I can
> select the specific data in the table and put it on the webpage,
> but I also
> want to edit this selected item.
stmt.execute("update ......");
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>