Ejecutar el siguiente script
/****** Object: Database [BD_EjemploJDBC] Script Date: 04/01/2013 20:08:04 ******/
CREATE DATABASE [BD_EjemploJDBC]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[TComentario](
[Id] [numeric](18, 0) IDENTITY(1,1) NOT NULL,
[Nombres] [varchar](100) NULL,
[email] [varchar](50) NULL,
[dni] [char](8) NULL,
[observacion] [varchar](500) NULL,
CONSTRAINT [PK_TComentario] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
Crear el siguiente procedimiento almacenado
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
CREATE PROCEDURE SPI_TComentario
@Nombres varchar(100)
,@Email varchar(50)
,@Dni char(8)
,@Observacion varchar(500)
AS
BEGIN
SET NOCOUNT ON;
Insert Into dbo.TComentario(
Nombres,email,dni, observacion)
values (
@Nombres, @Email, @Dni, @Observacion)
END
GO
Poner en el cuerpo del documento del index.jsp el siguiente formulario:
/****** Object: Database [BD_EjemploJDBC] Script Date: 04/01/2013 20:08:04 ******/
CREATE DATABASE [BD_EjemploJDBC]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[TComentario](
[Id] [numeric](18, 0) IDENTITY(1,1) NOT NULL,
[Nombres] [varchar](100) NULL,
[email] [varchar](50) NULL,
[dni] [char](8) NULL,
[observacion] [varchar](500) NULL,
CONSTRAINT [PK_TComentario] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
Crear el siguiente procedimiento almacenado
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
CREATE PROCEDURE SPI_TComentario
@Nombres varchar(100)
,@Email varchar(50)
,@Dni char(8)
,@Observacion varchar(500)
AS
BEGIN
SET NOCOUNT ON;
Insert Into dbo.TComentario(
Nombres,email,dni, observacion)
values (
@Nombres, @Email, @Dni, @Observacion)
END
GO
Poner en el cuerpo del documento del index.jsp el siguiente formulario:
<div align="center"> <h1>Envianos tu Opinion</h1> <form action="ServletComentario" method="Post"> <table> <tr> <td>Nombres</td> <td><input type="text" name="txtNombres" value="" maxlength="100" /> </td> </tr> <tr> <td>Email</td> <td><input type="text" name="txtEmail" value="" maxlength="50" /></td> </tr> <tr> <td>Dni</td> <td><input type="text" name="txtDni" value="" maxlength="8" /></td> </tr> <tr> <td>Observacion</td> <td><textarea name="txtObservacion" rows="4" cols="40" > </textarea></td> </tr> <tr> <td rowspan="2"> <input type="submit" value="Enviar Coment" name="btnEnviar" /> </td> </tr> </table> </form> </div>
:)
ResponderEliminar