Soumettre la recherche
Mettre en ligne
VISUALIZAR REGISTROS EN UN JTABLE
•
Télécharger en tant que DOCX, PDF
•
2 j'aime
•
3,524 vues
Darwin Durand
Suivre
Formation
Signaler
Partager
Signaler
Partager
1 sur 5
Télécharger maintenant
Recommandé
INSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVER
INSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVER
Darwin Durand
SISTEMA DE FACTURACION (Ejemplo desarrollado)
SISTEMA DE FACTURACION (Ejemplo desarrollado)
Darwin Durand
Visual Studio.Net - Sql Server
Visual Studio.Net - Sql Server
Darwin Durand
Sistema de ventas
Sistema de ventas
DAYANA RETO
Ensure code quality with vs2012
Ensure code quality with vs2012
Sandeep Joshi
Ss
Ss
Karan Soni
Ds 2 cycle
Ds 2 cycle
Chaitanya Kn
Developer Experience i TypeScript. Najbardziej ikoniczne duo
Developer Experience i TypeScript. Najbardziej ikoniczne duo
The Software House
Recommandé
INSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVER
INSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVER
Darwin Durand
SISTEMA DE FACTURACION (Ejemplo desarrollado)
SISTEMA DE FACTURACION (Ejemplo desarrollado)
Darwin Durand
Visual Studio.Net - Sql Server
Visual Studio.Net - Sql Server
Darwin Durand
Sistema de ventas
Sistema de ventas
DAYANA RETO
Ensure code quality with vs2012
Ensure code quality with vs2012
Sandeep Joshi
Ss
Ss
Karan Soni
Ds 2 cycle
Ds 2 cycle
Chaitanya Kn
Developer Experience i TypeScript. Najbardziej ikoniczne duo
Developer Experience i TypeScript. Najbardziej ikoniczne duo
The Software House
code for quiz in my sql
code for quiz in my sql
JOYITAKUNDU1
Promise: async programming hero
Promise: async programming hero
The Software House
Ip project
Ip project
Jasmeet Singh
Pre zen ta sion
Pre zen ta sion
Sajid Alee Mosavi
Specs2
Specs2
Piyush Mishra
Rxjs vienna
Rxjs vienna
Christoffer Noring
LetSwift RxSwift 시작하기
LetSwift RxSwift 시작하기
Wanbok Choi
MaintainStaffTable
MaintainStaffTable
William Rutherford
Ip project visual mobile
Ip project visual mobile
Kendriya vidyalaya no.1 cantt shahjahanpur
The Ring programming language version 1.5.3 book - Part 44 of 184
The Ring programming language version 1.5.3 book - Part 44 of 184
Mahmoud Samir Fayed
Create a Customized GMF DnD Framework
Create a Customized GMF DnD Framework
Kaniska Mandal
The Ring programming language version 1.7 book - Part 10 of 196
The Ring programming language version 1.7 book - Part 10 of 196
Mahmoud Samir Fayed
Async code on kotlin: rx java or/and coroutines - Kotlin Night Turin
Async code on kotlin: rx java or/and coroutines - Kotlin Night Turin
Fabio Collini
드로이드 나이츠 2018: RxJava 적용 팁 및 트러블 슈팅
드로이드 나이츠 2018: RxJava 적용 팁 및 트러블 슈팅
재춘 노
Jason parsing
Jason parsing
parallelminder
javascript function & closure
javascript function & closure
Hika Maeng
Rajeev oops 2nd march
Rajeev oops 2nd march
Rajeev Sharan
Component lifecycle hooks in Angular 2.0
Component lifecycle hooks in Angular 2.0
Eyal Vardi
Student management system
Student management system
geetika goyal
AJUG April 2011 Cascading example
AJUG April 2011 Cascading example
Christopher Curtin
DAOFactory.javaDAOFactory.javapublicclassDAOFactory{ this .docx
DAOFactory.javaDAOFactory.javapublicclassDAOFactory{ this .docx
theodorelove43763
database propertiesjdbc.url=jdbcderbyBigJavaDB;create=true # .pdf
database propertiesjdbc.url=jdbcderbyBigJavaDB;create=true # .pdf
fashiionbeutycare
Contenu connexe
Tendances
code for quiz in my sql
code for quiz in my sql
JOYITAKUNDU1
Promise: async programming hero
Promise: async programming hero
The Software House
Ip project
Ip project
Jasmeet Singh
Pre zen ta sion
Pre zen ta sion
Sajid Alee Mosavi
Specs2
Specs2
Piyush Mishra
Rxjs vienna
Rxjs vienna
Christoffer Noring
LetSwift RxSwift 시작하기
LetSwift RxSwift 시작하기
Wanbok Choi
MaintainStaffTable
MaintainStaffTable
William Rutherford
Ip project visual mobile
Ip project visual mobile
Kendriya vidyalaya no.1 cantt shahjahanpur
The Ring programming language version 1.5.3 book - Part 44 of 184
The Ring programming language version 1.5.3 book - Part 44 of 184
Mahmoud Samir Fayed
Create a Customized GMF DnD Framework
Create a Customized GMF DnD Framework
Kaniska Mandal
The Ring programming language version 1.7 book - Part 10 of 196
The Ring programming language version 1.7 book - Part 10 of 196
Mahmoud Samir Fayed
Async code on kotlin: rx java or/and coroutines - Kotlin Night Turin
Async code on kotlin: rx java or/and coroutines - Kotlin Night Turin
Fabio Collini
드로이드 나이츠 2018: RxJava 적용 팁 및 트러블 슈팅
드로이드 나이츠 2018: RxJava 적용 팁 및 트러블 슈팅
재춘 노
Jason parsing
Jason parsing
parallelminder
javascript function & closure
javascript function & closure
Hika Maeng
Rajeev oops 2nd march
Rajeev oops 2nd march
Rajeev Sharan
Component lifecycle hooks in Angular 2.0
Component lifecycle hooks in Angular 2.0
Eyal Vardi
Student management system
Student management system
geetika goyal
Tendances
(19)
code for quiz in my sql
code for quiz in my sql
Promise: async programming hero
Promise: async programming hero
Ip project
Ip project
Pre zen ta sion
Pre zen ta sion
Specs2
Specs2
Rxjs vienna
Rxjs vienna
LetSwift RxSwift 시작하기
LetSwift RxSwift 시작하기
MaintainStaffTable
MaintainStaffTable
Ip project visual mobile
Ip project visual mobile
The Ring programming language version 1.5.3 book - Part 44 of 184
The Ring programming language version 1.5.3 book - Part 44 of 184
Create a Customized GMF DnD Framework
Create a Customized GMF DnD Framework
The Ring programming language version 1.7 book - Part 10 of 196
The Ring programming language version 1.7 book - Part 10 of 196
Async code on kotlin: rx java or/and coroutines - Kotlin Night Turin
Async code on kotlin: rx java or/and coroutines - Kotlin Night Turin
드로이드 나이츠 2018: RxJava 적용 팁 및 트러블 슈팅
드로이드 나이츠 2018: RxJava 적용 팁 및 트러블 슈팅
Jason parsing
Jason parsing
javascript function & closure
javascript function & closure
Rajeev oops 2nd march
Rajeev oops 2nd march
Component lifecycle hooks in Angular 2.0
Component lifecycle hooks in Angular 2.0
Student management system
Student management system
Similaire à VISUALIZAR REGISTROS EN UN JTABLE
AJUG April 2011 Cascading example
AJUG April 2011 Cascading example
Christopher Curtin
DAOFactory.javaDAOFactory.javapublicclassDAOFactory{ this .docx
DAOFactory.javaDAOFactory.javapublicclassDAOFactory{ this .docx
theodorelove43763
database propertiesjdbc.url=jdbcderbyBigJavaDB;create=true # .pdf
database propertiesjdbc.url=jdbcderbyBigJavaDB;create=true # .pdf
fashiionbeutycare
#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...
#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...
탑크리에듀(구로디지털단지역3번출구 2분거리)
TypeScript Introduction
TypeScript Introduction
Dmitry Sheiko
Scala in practice
Scala in practice
andyrobinson8
CSharp v1.0.2
CSharp v1.0.2
Srdjan Pajic
Easy Button
Easy Button
Adam Dale
Android Design Patterns
Android Design Patterns
Godfrey Nolan
srcArtifact.javasrcArtifact.javaclassArtifactextendsCave{pub.docx
srcArtifact.javasrcArtifact.javaclassArtifactextendsCave{pub.docx
whitneyleman54422
Google guava
Google guava
Thomas Ferris Nicolaisen
3. Объекты, классы и пакеты в Java
3. Объекты, классы и пакеты в Java
DEVTYPE
Beautiful java script
Beautiful java script
Ürgo Ringo
Ast transformations
Ast transformations
HamletDRC
Guice2.0
Guice2.0
Masaaki Yonebayashi
Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...
Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...
.NET Conf UY
Griffon @ Svwjug
Griffon @ Svwjug
Andres Almiray
What’s new in C# 6
What’s new in C# 6
Fiyaz Hasan
Greach, GroovyFx Workshop
Greach, GroovyFx Workshop
Dierk König
1 MVC – Ajax and Modal Views AJAX stands for Asynch.docx
1 MVC – Ajax and Modal Views AJAX stands for Asynch.docx
honey725342
Similaire à VISUALIZAR REGISTROS EN UN JTABLE
(20)
AJUG April 2011 Cascading example
AJUG April 2011 Cascading example
DAOFactory.javaDAOFactory.javapublicclassDAOFactory{ this .docx
DAOFactory.javaDAOFactory.javapublicclassDAOFactory{ this .docx
database propertiesjdbc.url=jdbcderbyBigJavaDB;create=true # .pdf
database propertiesjdbc.url=jdbcderbyBigJavaDB;create=true # .pdf
#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...
#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...
TypeScript Introduction
TypeScript Introduction
Scala in practice
Scala in practice
CSharp v1.0.2
CSharp v1.0.2
Easy Button
Easy Button
Android Design Patterns
Android Design Patterns
srcArtifact.javasrcArtifact.javaclassArtifactextendsCave{pub.docx
srcArtifact.javasrcArtifact.javaclassArtifactextendsCave{pub.docx
Google guava
Google guava
3. Объекты, классы и пакеты в Java
3. Объекты, классы и пакеты в Java
Beautiful java script
Beautiful java script
Ast transformations
Ast transformations
Guice2.0
Guice2.0
Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...
Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...
Griffon @ Svwjug
Griffon @ Svwjug
What’s new in C# 6
What’s new in C# 6
Greach, GroovyFx Workshop
Greach, GroovyFx Workshop
1 MVC – Ajax and Modal Views AJAX stands for Asynch.docx
1 MVC – Ajax and Modal Views AJAX stands for Asynch.docx
Plus de Darwin Durand
Ejemplos Borland C++ Builder
Ejemplos Borland C++ Builder
Darwin Durand
EJEMPLOS DESARROLLADOS
EJEMPLOS DESARROLLADOS
Darwin Durand
PERSISTENCIA BASADA EN ARCHIVOS
PERSISTENCIA BASADA EN ARCHIVOS
Darwin Durand
PROYECTO PRUEBA DE CONEXIONES (Mantenimiento)
PROYECTO PRUEBA DE CONEXIONES (Mantenimiento)
Darwin Durand
CONEXION VISUAL STUDIO.NET - SQL SERVER
CONEXION VISUAL STUDIO.NET - SQL SERVER
Darwin Durand
CREACION DE DLL Y USO (Ejemplo desarrollado)
CREACION DE DLL Y USO (Ejemplo desarrollado)
Darwin Durand
CURSO DE PROGRAMACION AVANZADA EN JAVA EN ESPAÑOL
CURSO DE PROGRAMACION AVANZADA EN JAVA EN ESPAÑOL
Darwin Durand
SERVLET BASICS
SERVLET BASICS
Darwin Durand
INDICES EN SQL SERVER
INDICES EN SQL SERVER
Darwin Durand
INTEGRIDAD DE DATOS
INTEGRIDAD DE DATOS
Darwin Durand
APLICACIONES EMPRESARIALES
APLICACIONES EMPRESARIALES
Darwin Durand
CREACION Y MANEJO DE LA BASE DE DATOS
CREACION Y MANEJO DE LA BASE DE DATOS
Darwin Durand
CREACION DE TABLAS
CREACION DE TABLAS
Darwin Durand
Plus de Darwin Durand
(13)
Ejemplos Borland C++ Builder
Ejemplos Borland C++ Builder
EJEMPLOS DESARROLLADOS
EJEMPLOS DESARROLLADOS
PERSISTENCIA BASADA EN ARCHIVOS
PERSISTENCIA BASADA EN ARCHIVOS
PROYECTO PRUEBA DE CONEXIONES (Mantenimiento)
PROYECTO PRUEBA DE CONEXIONES (Mantenimiento)
CONEXION VISUAL STUDIO.NET - SQL SERVER
CONEXION VISUAL STUDIO.NET - SQL SERVER
CREACION DE DLL Y USO (Ejemplo desarrollado)
CREACION DE DLL Y USO (Ejemplo desarrollado)
CURSO DE PROGRAMACION AVANZADA EN JAVA EN ESPAÑOL
CURSO DE PROGRAMACION AVANZADA EN JAVA EN ESPAÑOL
SERVLET BASICS
SERVLET BASICS
INDICES EN SQL SERVER
INDICES EN SQL SERVER
INTEGRIDAD DE DATOS
INTEGRIDAD DE DATOS
APLICACIONES EMPRESARIALES
APLICACIONES EMPRESARIALES
CREACION Y MANEJO DE LA BASE DE DATOS
CREACION Y MANEJO DE LA BASE DE DATOS
CREACION DE TABLAS
CREACION DE TABLAS
Dernier
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
Steve Thomason
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
dawncurless
microwave assisted reaction. General introduction
microwave assisted reaction. General introduction
Maksud Ahmed
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
pragatimahajan3
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
Thiyagu K
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
Association for Project Management
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
National Information Standards Organization (NISO)
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
Celine George
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
National Information Standards Organization (NISO)
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
chloefrazer622
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
eniolaolutunde
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
TechSoup
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
GaneshChakor2
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
Sayali Powar
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Sapana Sha
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
misteraugie
Dernier
(20)
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
microwave assisted reaction. General introduction
microwave assisted reaction. General introduction
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
VISUALIZAR REGISTROS EN UN JTABLE
1.
VISUALIZAR REGISTROS (BD.
NORTHWIND) EN UN JTABLE (NETBEANS – SQL SERVER)<br />CONSULTA<br />select P.ProductID, <br />P.ProductName, <br />C.CategoryName, <br />S.CompanyName, <br />P.UnitPrice, <br />P.UnitsInStock, <br />P.QuantityPerUnit<br />from Products P inner join Categories C <br />on P.CategoryID = C.CategoryID <br /> inner join Suppliers S<br /> on P.SupplierID = S.SupplierID<br />ConnectionManager<br />package examen;<br />import java.sql.Connection;<br />import java.sql.DriverManager;<br />import java.sql.SQLException;<br />public class ConnectionManager {<br /> final private static String DRIVER = quot; com.microsoft.sqlserver.jdbc.SQLServerDriverquot; ;<br /> final private static String URL = quot; jdbc:sqlserver://localhost:1433;DatabaseName=Northwindquot; ;<br /> final private static String USER = quot; saquot; ;<br /> final private static String PASSWORD = quot; 123quot; ;<br /> private static Connection cn = null;<br /> private ConnectionManager() {<br /> }<br /> public static Connection getConnection()<br /> throws ClassNotFoundException,<br /> SQLException,<br /> Exception {<br /> if (cn == null) {<br /> try {<br /> Class.forName(DRIVER).newInstance();<br /> cn = DriverManager.getConnection(URL, USER, PASSWORD);<br /> } catch (ClassNotFoundException ex) {<br /> throw ex;<br /> } catch (SQLException ex) {<br /> throw ex;<br /> } catch (Exception ex) {<br /> throw ex;<br /> }<br /> }<br /> return cn;<br /> }<br />}<br />Producto<br />package examen;<br />import java.io.Serializable;<br />public class Producto implements Serializable {<br /> private int ProductId;<br /> private String ProductName;<br /> private String CategoryName;<br /> private String CompanyName;<br /> private double UnitPrice;<br /> private int UnitStock;<br /> private String UnidadMedidad;<br /> public Producto() {<br /> }<br /> public Producto(int ProductId, String ProductName, String CategoryName, String CompanyName, double UnitPrice, int UnitStock, String UnidadMedidad) {<br /> this.ProductId = ProductId;<br /> this.ProductName = ProductName;<br /> this.CategoryName = CategoryName;<br /> this.CompanyName = CompanyName;<br /> this.UnitPrice = UnitPrice;<br /> this.UnitStock = UnitStock;<br /> this.UnidadMedidad = UnidadMedidad;<br /> }<br /> public String getCategoryName() {<br /> return CategoryName;<br /> }<br /> public void setCategoryName(String CategoryName) {<br /> this.CategoryName = CategoryName;<br /> }<br /> public String getCompanyName() {<br /> return CompanyName;<br /> }<br /> public void setCompanyName(String CompanyName) {<br /> this.CompanyName = CompanyName;<br /> }<br /> public int getProductId() {<br /> return ProductId;<br /> }<br /> public void setProductId(int ProductId) {<br /> this.ProductId = ProductId;<br /> }<br /> public String getProductName() {<br /> return ProductName;<br /> }<br /> public void setProductName(String ProductName) {<br /> this.ProductName = ProductName;<br /> }<br /> public String getUnidadMedidad() {<br /> return UnidadMedidad;<br /> }<br /> public void setUnidadMedidad(String UnidadMedidad) {<br /> this.UnidadMedidad = UnidadMedidad;<br /> }<br /> public double getUnitPrice() {<br /> return UnitPrice;<br /> }<br /> public void setUnitPrice(double UnitPrice) {<br /> this.UnitPrice = UnitPrice;<br /> }<br /> public int getUnitStock() {<br /> return UnitStock;<br /> }<br /> public void setUnitStock(int UnitStock) {<br /> this.UnitStock = UnitStock;<br /> }<br />}<br />ProductoDAO <br />package examen;<br />import java.sql.CallableStatement;<br />import java.sql.Connection;<br />import java.sql.PreparedStatement;<br />import java.sql.ResultSet;<br />import java.sql.SQLException;<br />import java.sql.Statement;<br />import java.util.ArrayList;<br />public class ProductoDAO {<br /> private Connection cn = null;<br /> private Statement st = null;<br /> private PreparedStatement ps = null;<br /> private CallableStatement cs = null;<br /> private ResultSet rs = null;<br /> public ArrayList<Producto> getProducto() {<br /> ArrayList<Producto> productos =<br /> new ArrayList<Producto>();<br /> final String QUERY = quot; select p.ProductID , p.ProductName, C.CategoryName, s.CompanyName, p.UnitPrice, p.UnitsInStock, p.QuantityPerUnit from Products p inner join Categories c on p.CategoryID = C.CategoryID inner join Suppliers s on p.SupplierID = s.SupplierID quot; ;<br /> try {<br /> cn = ConnectionManager.getConnection();<br /> st = cn.createStatement();<br /> rs = st.executeQuery(QUERY);<br /> while (rs.next()) {<br /> Producto c = new Producto(<br /> rs.getInt(1),<br /> rs.getString(2),<br /> rs.getString(3),<br /> rs.getString(4),<br /> rs.getDouble(5),<br /> rs.getInt(6),<br /> rs.getString(7));<br /> productos.add(c);<br /> }<br /> } catch (SQLException ex) {<br /> } catch (Exception ex) {<br /> } finally {<br /> try {<br /> if (rs != null) {<br /> rs.close();<br /> }<br /> if (st != null) {<br /> st.close();<br /> }<br /> if (cn != null) {<br /> cn.close();<br /> }<br /> } catch (Exception ex) {<br /> }<br /> }<br /> return productos;<br /> }<br />}<br />CODIGO FUENTE<br />package examen;<br />import java.util.ArrayList;<br />import java.util.Vector;<br />import javax.swing.table.DefaultTableModel;<br />import javax.swing.table.TableColumn;<br />public class FrmConsultaProductos extends javax.swing.JFrame {<br /> private DefaultTableModel dtm;<br /> public FrmConsultaProductos() {<br /> initComponents();<br /> configurartabla();<br /> cargartabla();<br /> }<br />public static void main(String args[]) {<br /> java.awt.EventQueue.invokeLater(new Runnable() {<br /> public void run() {<br /> new FrmConsultaProductos().setVisible(true);<br /> }<br /> });<br /> }<br /> // Variables declaration - do not modify <br /> private javax.swing.JScrollPane jScrollPane1;<br /> private javax.swing.JTable tblProducto;<br /> // End of variables declaration <br /> private void cargartabla() {<br /> ProductoDAO bo = new ProductoDAO();<br /> ArrayList<Producto> productos =<br /> bo.getProducto();<br /> dtm = (DefaultTableModel) tblProducto.getModel();<br /> for (Producto c : productos) {<br /> Vector fila = new Vector();<br /> fila.add(c.getProductId());<br /> fila.add(c.getProductName());<br /> fila.add(c.getCategoryName());<br /> fila.add(c.getCompanyName());<br /> fila.add(c.getUnitPrice());<br /> fila.add(c.getUnitStock());<br /> fila.add(c.getUnidadMedidad());<br /> dtm.addRow(fila);<br /> }<br /> }<br /> private void configurartabla() {<br /> TableColumn column = null;<br /> column = tblProducto.getColumnModel().getColumn(0);<br /> column.setPreferredWidth(2);<br /> column = tblProducto.getColumnModel().getColumn(1);<br /> column.setPreferredWidth(150);<br /> column = tblProducto.getColumnModel().getColumn(2);<br /> column.setPreferredWidth(150);<br /> }<br />}<br />
Télécharger maintenant