SlideShare uma empresa Scribd logo
1 de 17
Baixar para ler offline
16 de enero
                                   TUTORIAL ENCAPSULAR OBJETOS JDBC
                                                                               de 2011

                       Tutorial Encapsular Objetos JDBC

1. Clase ConexionBaseDatos
   En el tutorial Creacion de un Datasource con NetBeans y MySQL,ese Datasource
   creado se va a representar mediante código en nuestras aplicaciones , normalmente en
   un archivo de Contexto como vemos en la siguiente figura:




   Partiendo del archivo Context,la clase ConexionBaseDatos interactua con el archivo
   context.xml (nodo Web Pages/META-INF) del proyecto, y establece la conexión a la
   base de datos. Tiene solo el método getConexion() que retorna un objeto Connection ,
   especificando el nombre del Datasource, su código es:




         ING. HENRY MENDOZA PUERTA (HENRY_MENDO@HOTMAIL.COM)
16 de enero
                                     TUTORIAL ENCAPSULAR OBJETOS JDBC
                                                                                   de 2011




2. Clase JDBCSql
   Con la conexión a la BD activa, los métodos de la clase JDBCSql ejecutan diversas
   funciones SQL como servicios a las aplicaciones , a fin de separar totalmente el código
   de acceso a datos del código de presentación.




          ING. HENRY MENDOZA PUERTA (HENRY_MENDO@HOTMAIL.COM)
16 de enero
                                  TUTORIAL ENCAPSULAR OBJETOS JDBC
                                                                                de 2011

Método FillCombo, recibe un SELECT con dos columnas , la primera columna será el
value y la segunda columna la option de un objeto select ( en HTML) que este método
retornara.--

Método Query retorna una consulta embebida en un objeto List . Tenemos dos
métodos de consulta, la que retorna todas las filas y la que retorna paginas de consulta,
esto cuando son muchas filas. El cliente tendrá que extraer los datos del objeto List.-

Método QueryHtml retorna un SELECT embebido en un objeto table (en HTML) .
Tenemos dos métodos consulta, la que retorna todas las filas y la que retorna paginas de
consulta.-

Métodos countRows, recibe un SELECT y retorna la cantidad de filas existentes en
dicha consulta.

Método ExecComando debe recibir un INSERT,DELETE o UPDATE , para ejecutar
. Si tiene éxito retorna null ,caso contrario el mensaje de error de porque no pudo hacer
dicha operación.-

Método getCampo debe recibir un SELECT con una condición WHERE a fin de
retornar solo un Object que es el datos requerido por el cliente.

Método getFila debe recibir un SELECT con una condición WHERE a fin de retornar
solo una fila en un arreglo Object . El cliente tendra que extraer los datos del arreglo
Object.




      ING. HENRY MENDOZA PUERTA (HENRY_MENDO@HOTMAIL.COM)
16 de enero
                          TUTORIAL ENCAPSULAR OBJETOS JDBC
                                                                 de 2011

Codigo de Clase JDBCSql




    ING. HENRY MENDOZA PUERTA (HENRY_MENDO@HOTMAIL.COM)
16 de enero
                    TUTORIAL ENCAPSULAR OBJETOS JDBC
                                                           de 2011




ING. HENRY MENDOZA PUERTA (HENRY_MENDO@HOTMAIL.COM)
16 de enero
                    TUTORIAL ENCAPSULAR OBJETOS JDBC
                                                           de 2011




ING. HENRY MENDOZA PUERTA (HENRY_MENDO@HOTMAIL.COM)
16 de enero
                    TUTORIAL ENCAPSULAR OBJETOS JDBC
                                                           de 2011




ING. HENRY MENDOZA PUERTA (HENRY_MENDO@HOTMAIL.COM)
16 de enero
                    TUTORIAL ENCAPSULAR OBJETOS JDBC
                                                           de 2011




ING. HENRY MENDOZA PUERTA (HENRY_MENDO@HOTMAIL.COM)
16 de enero
                    TUTORIAL ENCAPSULAR OBJETOS JDBC
                                                           de 2011




ING. HENRY MENDOZA PUERTA (HENRY_MENDO@HOTMAIL.COM)
16 de enero
                                    TUTORIAL ENCAPSULAR OBJETOS JDBC
                                                                                de 2011




3. El siguiente proyecto , servirá para probar los métodos de la clase JDBCSql , es un
   proyecto web con acceso a la base datos que se indica en el archivo Context(Ver Paso
   1 de este tutorial) , Seleccionar Tomcat como servidor web, y no usar ningún
   framework .




         ING. HENRY MENDOZA PUERTA (HENRY_MENDO@HOTMAIL.COM)
16 de enero
                                TUTORIAL ENCAPSULAR OBJETOS JDBC
                                                                       de 2011

Contenido de index.jsp




Su salida en el browser será:




      ING. HENRY MENDOZA PUERTA (HENRY_MENDO@HOTMAIL.COM)
16 de enero
                                TUTORIAL ENCAPSULAR OBJETOS JDBC
                                                                       de 2011

El contenido de QueryHtml.jsp




Su salida en el browser será:




      ING. HENRY MENDOZA PUERTA (HENRY_MENDO@HOTMAIL.COM)
16 de enero
                                TUTORIAL ENCAPSULAR OBJETOS JDBC
                                                                       de 2011

Contenido de FillCombo.jsp es




Su salida en el browser será:




      ING. HENRY MENDOZA PUERTA (HENRY_MENDO@HOTMAIL.COM)
16 de enero
                                TUTORIAL ENCAPSULAR OBJETOS JDBC
                                                                       de 2011


Contenido de getFila.jsp es:




Su salida en el browser será:




      ING. HENRY MENDOZA PUERTA (HENRY_MENDO@HOTMAIL.COM)
16 de enero
                                TUTORIAL ENCAPSULAR OBJETOS JDBC
                                                                       de 2011

Contenido de getCampo.jsp es:




Su salida en el browser será:




      ING. HENRY MENDOZA PUERTA (HENRY_MENDO@HOTMAIL.COM)
16 de enero
                              TUTORIAL ENCAPSULAR OBJETOS JDBC
                                                                     de 2011

Contenido de QueryPaginado.jsp es:




     ING. HENRY MENDOZA PUERTA (HENRY_MENDO@HOTMAIL.COM)
16 de enero
                                TUTORIAL ENCAPSULAR OBJETOS JDBC
                                                                       de 2011


Su salida en el browser será:




      ING. HENRY MENDOZA PUERTA (HENRY_MENDO@HOTMAIL.COM)

Mais conteúdo relacionado

Último

El uso de las TIC's en la vida cotidiana.
El uso de las TIC's en la vida cotidiana.El uso de las TIC's en la vida cotidiana.
El uso de las TIC's en la vida cotidiana.241514949
 
Crear un recurso multimedia. Maricela_Ponce_DomingoM1S3AI6-1.pptx
Crear un recurso multimedia. Maricela_Ponce_DomingoM1S3AI6-1.pptxCrear un recurso multimedia. Maricela_Ponce_DomingoM1S3AI6-1.pptx
Crear un recurso multimedia. Maricela_Ponce_DomingoM1S3AI6-1.pptxNombre Apellidos
 
Mapa-conceptual-del-Origen-del-Universo-3.pptx
Mapa-conceptual-del-Origen-del-Universo-3.pptxMapa-conceptual-del-Origen-del-Universo-3.pptx
Mapa-conceptual-del-Origen-del-Universo-3.pptxMidwarHenryLOZAFLORE
 
Trabajo de tecnología excel avanzado.pdf
Trabajo de tecnología excel avanzado.pdfTrabajo de tecnología excel avanzado.pdf
Trabajo de tecnología excel avanzado.pdfedepmariaperez
 
Medidas de formas, coeficiente de asimetría y coeficiente de curtosis.pptx
Medidas de formas, coeficiente de asimetría y coeficiente de curtosis.pptxMedidas de formas, coeficiente de asimetría y coeficiente de curtosis.pptx
Medidas de formas, coeficiente de asimetría y coeficiente de curtosis.pptxaylincamaho
 
LAS_TIC_COMO_HERRAMIENTAS_EN_LA_INVESTIGACIÓN.pptx
LAS_TIC_COMO_HERRAMIENTAS_EN_LA_INVESTIGACIÓN.pptxLAS_TIC_COMO_HERRAMIENTAS_EN_LA_INVESTIGACIÓN.pptx
LAS_TIC_COMO_HERRAMIENTAS_EN_LA_INVESTIGACIÓN.pptxAlexander López
 
Los Microcontroladores PIC, Aplicaciones
Los Microcontroladores PIC, AplicacionesLos Microcontroladores PIC, Aplicaciones
Los Microcontroladores PIC, AplicacionesEdomar AR
 
FloresMorales_Montserrath_M1S3AI6 (1).pptx
FloresMorales_Montserrath_M1S3AI6 (1).pptxFloresMorales_Montserrath_M1S3AI6 (1).pptx
FloresMorales_Montserrath_M1S3AI6 (1).pptx241522327
 
Presentación sobre la Inteligencia Artificial
Presentación sobre la Inteligencia ArtificialPresentación sobre la Inteligencia Artificial
Presentación sobre la Inteligencia Artificialcynserafini89
 
Red Dorsal Nacional de Fibra Óptica y Redes Regionales del Perú
Red Dorsal Nacional de Fibra Óptica y Redes Regionales del PerúRed Dorsal Nacional de Fibra Óptica y Redes Regionales del Perú
Red Dorsal Nacional de Fibra Óptica y Redes Regionales del PerúCEFERINO DELGADO FLORES
 
Tecnologias Starlink para el mundo tec.pptx
Tecnologias Starlink para el mundo tec.pptxTecnologias Starlink para el mundo tec.pptx
Tecnologias Starlink para el mundo tec.pptxGESTECPERUSAC
 
La Electricidad Y La Electrónica Trabajo Tecnología.pdf
La Electricidad Y La Electrónica Trabajo Tecnología.pdfLa Electricidad Y La Electrónica Trabajo Tecnología.pdf
La Electricidad Y La Electrónica Trabajo Tecnología.pdfjeondanny1997
 
Actividad integradora 6 CREAR UN RECURSO MULTIMEDIA
Actividad integradora 6    CREAR UN RECURSO MULTIMEDIAActividad integradora 6    CREAR UN RECURSO MULTIMEDIA
Actividad integradora 6 CREAR UN RECURSO MULTIMEDIA241531640
 
LUXOMETRO EN SALUD OCUPACIONAL(FINAL).ppt
LUXOMETRO EN SALUD OCUPACIONAL(FINAL).pptLUXOMETRO EN SALUD OCUPACIONAL(FINAL).ppt
LUXOMETRO EN SALUD OCUPACIONAL(FINAL).pptchaverriemily794
 
Excel (1) tecnologia.pdf trabajo Excel taller
Excel  (1) tecnologia.pdf trabajo Excel tallerExcel  (1) tecnologia.pdf trabajo Excel taller
Excel (1) tecnologia.pdf trabajo Excel tallerValentinaTabares11
 
tics en la vida cotidiana prepa en linea modulo 1.pptx
tics en la vida cotidiana prepa en linea modulo 1.pptxtics en la vida cotidiana prepa en linea modulo 1.pptx
tics en la vida cotidiana prepa en linea modulo 1.pptxazmysanros90
 
tarea de exposicion de senati zzzzzzzzzz
tarea de exposicion de senati zzzzzzzzzztarea de exposicion de senati zzzzzzzzzz
tarea de exposicion de senati zzzzzzzzzzAlexandergo5
 
AREA TECNOLOGIA E INFORMATICA TRABAJO EN EQUIPO
AREA TECNOLOGIA E INFORMATICA TRABAJO EN EQUIPOAREA TECNOLOGIA E INFORMATICA TRABAJO EN EQUIPO
AREA TECNOLOGIA E INFORMATICA TRABAJO EN EQUIPOnarvaezisabella21
 
Modelo de Presentacion Feria Robotica Educativa 2024 - Versión3.pptx
Modelo de Presentacion Feria Robotica Educativa 2024 - Versión3.pptxModelo de Presentacion Feria Robotica Educativa 2024 - Versión3.pptx
Modelo de Presentacion Feria Robotica Educativa 2024 - Versión3.pptxtjcesar1
 
El uso de las tic en la vida ,lo importante que son
El uso de las tic en la vida ,lo importante  que sonEl uso de las tic en la vida ,lo importante  que son
El uso de las tic en la vida ,lo importante que son241514984
 

Último (20)

El uso de las TIC's en la vida cotidiana.
El uso de las TIC's en la vida cotidiana.El uso de las TIC's en la vida cotidiana.
El uso de las TIC's en la vida cotidiana.
 
Crear un recurso multimedia. Maricela_Ponce_DomingoM1S3AI6-1.pptx
Crear un recurso multimedia. Maricela_Ponce_DomingoM1S3AI6-1.pptxCrear un recurso multimedia. Maricela_Ponce_DomingoM1S3AI6-1.pptx
Crear un recurso multimedia. Maricela_Ponce_DomingoM1S3AI6-1.pptx
 
Mapa-conceptual-del-Origen-del-Universo-3.pptx
Mapa-conceptual-del-Origen-del-Universo-3.pptxMapa-conceptual-del-Origen-del-Universo-3.pptx
Mapa-conceptual-del-Origen-del-Universo-3.pptx
 
Trabajo de tecnología excel avanzado.pdf
Trabajo de tecnología excel avanzado.pdfTrabajo de tecnología excel avanzado.pdf
Trabajo de tecnología excel avanzado.pdf
 
Medidas de formas, coeficiente de asimetría y coeficiente de curtosis.pptx
Medidas de formas, coeficiente de asimetría y coeficiente de curtosis.pptxMedidas de formas, coeficiente de asimetría y coeficiente de curtosis.pptx
Medidas de formas, coeficiente de asimetría y coeficiente de curtosis.pptx
 
LAS_TIC_COMO_HERRAMIENTAS_EN_LA_INVESTIGACIÓN.pptx
LAS_TIC_COMO_HERRAMIENTAS_EN_LA_INVESTIGACIÓN.pptxLAS_TIC_COMO_HERRAMIENTAS_EN_LA_INVESTIGACIÓN.pptx
LAS_TIC_COMO_HERRAMIENTAS_EN_LA_INVESTIGACIÓN.pptx
 
Los Microcontroladores PIC, Aplicaciones
Los Microcontroladores PIC, AplicacionesLos Microcontroladores PIC, Aplicaciones
Los Microcontroladores PIC, Aplicaciones
 
FloresMorales_Montserrath_M1S3AI6 (1).pptx
FloresMorales_Montserrath_M1S3AI6 (1).pptxFloresMorales_Montserrath_M1S3AI6 (1).pptx
FloresMorales_Montserrath_M1S3AI6 (1).pptx
 
Presentación sobre la Inteligencia Artificial
Presentación sobre la Inteligencia ArtificialPresentación sobre la Inteligencia Artificial
Presentación sobre la Inteligencia Artificial
 
Red Dorsal Nacional de Fibra Óptica y Redes Regionales del Perú
Red Dorsal Nacional de Fibra Óptica y Redes Regionales del PerúRed Dorsal Nacional de Fibra Óptica y Redes Regionales del Perú
Red Dorsal Nacional de Fibra Óptica y Redes Regionales del Perú
 
Tecnologias Starlink para el mundo tec.pptx
Tecnologias Starlink para el mundo tec.pptxTecnologias Starlink para el mundo tec.pptx
Tecnologias Starlink para el mundo tec.pptx
 
La Electricidad Y La Electrónica Trabajo Tecnología.pdf
La Electricidad Y La Electrónica Trabajo Tecnología.pdfLa Electricidad Y La Electrónica Trabajo Tecnología.pdf
La Electricidad Y La Electrónica Trabajo Tecnología.pdf
 
Actividad integradora 6 CREAR UN RECURSO MULTIMEDIA
Actividad integradora 6    CREAR UN RECURSO MULTIMEDIAActividad integradora 6    CREAR UN RECURSO MULTIMEDIA
Actividad integradora 6 CREAR UN RECURSO MULTIMEDIA
 
LUXOMETRO EN SALUD OCUPACIONAL(FINAL).ppt
LUXOMETRO EN SALUD OCUPACIONAL(FINAL).pptLUXOMETRO EN SALUD OCUPACIONAL(FINAL).ppt
LUXOMETRO EN SALUD OCUPACIONAL(FINAL).ppt
 
Excel (1) tecnologia.pdf trabajo Excel taller
Excel  (1) tecnologia.pdf trabajo Excel tallerExcel  (1) tecnologia.pdf trabajo Excel taller
Excel (1) tecnologia.pdf trabajo Excel taller
 
tics en la vida cotidiana prepa en linea modulo 1.pptx
tics en la vida cotidiana prepa en linea modulo 1.pptxtics en la vida cotidiana prepa en linea modulo 1.pptx
tics en la vida cotidiana prepa en linea modulo 1.pptx
 
tarea de exposicion de senati zzzzzzzzzz
tarea de exposicion de senati zzzzzzzzzztarea de exposicion de senati zzzzzzzzzz
tarea de exposicion de senati zzzzzzzzzz
 
AREA TECNOLOGIA E INFORMATICA TRABAJO EN EQUIPO
AREA TECNOLOGIA E INFORMATICA TRABAJO EN EQUIPOAREA TECNOLOGIA E INFORMATICA TRABAJO EN EQUIPO
AREA TECNOLOGIA E INFORMATICA TRABAJO EN EQUIPO
 
Modelo de Presentacion Feria Robotica Educativa 2024 - Versión3.pptx
Modelo de Presentacion Feria Robotica Educativa 2024 - Versión3.pptxModelo de Presentacion Feria Robotica Educativa 2024 - Versión3.pptx
Modelo de Presentacion Feria Robotica Educativa 2024 - Versión3.pptx
 
El uso de las tic en la vida ,lo importante que son
El uso de las tic en la vida ,lo importante  que sonEl uso de las tic en la vida ,lo importante  que son
El uso de las tic en la vida ,lo importante que son
 

Destaque

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Destaque (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Tutorial encapsular objetos jdbc

  • 1. 16 de enero TUTORIAL ENCAPSULAR OBJETOS JDBC de 2011 Tutorial Encapsular Objetos JDBC 1. Clase ConexionBaseDatos En el tutorial Creacion de un Datasource con NetBeans y MySQL,ese Datasource creado se va a representar mediante código en nuestras aplicaciones , normalmente en un archivo de Contexto como vemos en la siguiente figura: Partiendo del archivo Context,la clase ConexionBaseDatos interactua con el archivo context.xml (nodo Web Pages/META-INF) del proyecto, y establece la conexión a la base de datos. Tiene solo el método getConexion() que retorna un objeto Connection , especificando el nombre del Datasource, su código es: ING. HENRY MENDOZA PUERTA (HENRY_MENDO@HOTMAIL.COM)
  • 2. 16 de enero TUTORIAL ENCAPSULAR OBJETOS JDBC de 2011 2. Clase JDBCSql Con la conexión a la BD activa, los métodos de la clase JDBCSql ejecutan diversas funciones SQL como servicios a las aplicaciones , a fin de separar totalmente el código de acceso a datos del código de presentación. ING. HENRY MENDOZA PUERTA (HENRY_MENDO@HOTMAIL.COM)
  • 3. 16 de enero TUTORIAL ENCAPSULAR OBJETOS JDBC de 2011 Método FillCombo, recibe un SELECT con dos columnas , la primera columna será el value y la segunda columna la option de un objeto select ( en HTML) que este método retornara.-- Método Query retorna una consulta embebida en un objeto List . Tenemos dos métodos de consulta, la que retorna todas las filas y la que retorna paginas de consulta, esto cuando son muchas filas. El cliente tendrá que extraer los datos del objeto List.- Método QueryHtml retorna un SELECT embebido en un objeto table (en HTML) . Tenemos dos métodos consulta, la que retorna todas las filas y la que retorna paginas de consulta.- Métodos countRows, recibe un SELECT y retorna la cantidad de filas existentes en dicha consulta. Método ExecComando debe recibir un INSERT,DELETE o UPDATE , para ejecutar . Si tiene éxito retorna null ,caso contrario el mensaje de error de porque no pudo hacer dicha operación.- Método getCampo debe recibir un SELECT con una condición WHERE a fin de retornar solo un Object que es el datos requerido por el cliente. Método getFila debe recibir un SELECT con una condición WHERE a fin de retornar solo una fila en un arreglo Object . El cliente tendra que extraer los datos del arreglo Object. ING. HENRY MENDOZA PUERTA (HENRY_MENDO@HOTMAIL.COM)
  • 4. 16 de enero TUTORIAL ENCAPSULAR OBJETOS JDBC de 2011 Codigo de Clase JDBCSql ING. HENRY MENDOZA PUERTA (HENRY_MENDO@HOTMAIL.COM)
  • 5. 16 de enero TUTORIAL ENCAPSULAR OBJETOS JDBC de 2011 ING. HENRY MENDOZA PUERTA (HENRY_MENDO@HOTMAIL.COM)
  • 6. 16 de enero TUTORIAL ENCAPSULAR OBJETOS JDBC de 2011 ING. HENRY MENDOZA PUERTA (HENRY_MENDO@HOTMAIL.COM)
  • 7. 16 de enero TUTORIAL ENCAPSULAR OBJETOS JDBC de 2011 ING. HENRY MENDOZA PUERTA (HENRY_MENDO@HOTMAIL.COM)
  • 8. 16 de enero TUTORIAL ENCAPSULAR OBJETOS JDBC de 2011 ING. HENRY MENDOZA PUERTA (HENRY_MENDO@HOTMAIL.COM)
  • 9. 16 de enero TUTORIAL ENCAPSULAR OBJETOS JDBC de 2011 ING. HENRY MENDOZA PUERTA (HENRY_MENDO@HOTMAIL.COM)
  • 10. 16 de enero TUTORIAL ENCAPSULAR OBJETOS JDBC de 2011 3. El siguiente proyecto , servirá para probar los métodos de la clase JDBCSql , es un proyecto web con acceso a la base datos que se indica en el archivo Context(Ver Paso 1 de este tutorial) , Seleccionar Tomcat como servidor web, y no usar ningún framework . ING. HENRY MENDOZA PUERTA (HENRY_MENDO@HOTMAIL.COM)
  • 11. 16 de enero TUTORIAL ENCAPSULAR OBJETOS JDBC de 2011 Contenido de index.jsp Su salida en el browser será: ING. HENRY MENDOZA PUERTA (HENRY_MENDO@HOTMAIL.COM)
  • 12. 16 de enero TUTORIAL ENCAPSULAR OBJETOS JDBC de 2011 El contenido de QueryHtml.jsp Su salida en el browser será: ING. HENRY MENDOZA PUERTA (HENRY_MENDO@HOTMAIL.COM)
  • 13. 16 de enero TUTORIAL ENCAPSULAR OBJETOS JDBC de 2011 Contenido de FillCombo.jsp es Su salida en el browser será: ING. HENRY MENDOZA PUERTA (HENRY_MENDO@HOTMAIL.COM)
  • 14. 16 de enero TUTORIAL ENCAPSULAR OBJETOS JDBC de 2011 Contenido de getFila.jsp es: Su salida en el browser será: ING. HENRY MENDOZA PUERTA (HENRY_MENDO@HOTMAIL.COM)
  • 15. 16 de enero TUTORIAL ENCAPSULAR OBJETOS JDBC de 2011 Contenido de getCampo.jsp es: Su salida en el browser será: ING. HENRY MENDOZA PUERTA (HENRY_MENDO@HOTMAIL.COM)
  • 16. 16 de enero TUTORIAL ENCAPSULAR OBJETOS JDBC de 2011 Contenido de QueryPaginado.jsp es: ING. HENRY MENDOZA PUERTA (HENRY_MENDO@HOTMAIL.COM)
  • 17. 16 de enero TUTORIAL ENCAPSULAR OBJETOS JDBC de 2011 Su salida en el browser será: ING. HENRY MENDOZA PUERTA (HENRY_MENDO@HOTMAIL.COM)