Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners How To Display MS Access Table into Swing JTable

Have Programming Question? Ask it here!
 
 
 


shweta
How To Display MS Access Table into Swing JTable
1 Answer(s)      4 years and 4 months ago
Posted in : Java Beginners


How to Display Records From MS Access Database To JTable.
Plz Help Me

Advertisement
View Answers

April 6, 2010 at 11:43 AM


Hi Friend,

Try the following code:

import java.awt.*;
import java.sql.*;
import java.util.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.table.*;

public class JTableDatabase {
public static void main(String[] args) {
Vector columnNames = new Vector();
Vector data = new Vector();
JPanel p=new JPanel();
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:access");
String sql = "Select * from data";
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery( sql );
ResultSetMetaData md = rs.getMetaData();
int columns = md.getColumnCount();
for (int i = 1; i <= columns; i++) {
columnNames.addElement( md.getColumnName(i) );
}
while (rs.next()) {
Vector row = new Vector(columns);
for (int i = 1; i <= columns; i++){
row.addElement( rs.getObject(i) );
}
data.addElement( row );
}
rs.close();
stmt.close();
}
catch(Exception e){
System.out.println(e);
}
JTable table = new JTable(data, columnNames);
TableColumn col;
for (int i = 0; i < table.getColumnCount(); i++) {
col = table.getColumnModel().getColumn(i);
col.setMaxWidth(250);
}
JScrollPane scrollPane = new JScrollPane( table );
p.add( scrollPane );
JFrame f=new JFrame();
f.add(p);
f.setSize(600,400);
f.setVisible(true);
}
}

Thanks


Related Tutorials/Questions & Answers:
How To Display MS Access Table into Swing JTable - Java Beginners
How To Display MS Access Table into Swing JTable  How to Display Records From MS Access Database To JTable. Plz Help Me  Hi Friend...){ System.out.println(e); } JTable table = new JTable(data, columnNames); TableColumn
How To Display both image and data into Swing JTable which is retrieved from ms access database
How To Display both image and data into Swing JTable which is retrieved from ms access database  So far this is my code how can i display both image and data from database.. while (rs.next()) { Vector row = new Vector(columns
Advertisements
How to use JTable with MS-Access
How to use JTable with MS-Access   I have Three Column in Database (MS-Access). 1. Name 2. City 3. Contact I want to Display this data in JTable. How can I do it. I also want to EDIT and DELETE this Data
How to use JTable with MS-Access
How to use JTable with MS-Access   I have Three Column in Database (MS-Access). 1. Name 2. City 3. Contact I want to Display this data in JTable. How can I do it. I also want to EDIT and DELETE this Data
How To Insert A New Record to MS Access table database in GUI
How To Insert A New Record to MS Access table database in GUI  Hello, I've been working on the actionPerformed part of my java application that involves inserting a record into a 6-column table in my MS Access database table. I'm
How to Access MS Access in jar.
How to Access MS Access in jar.  how do i access my Ms-Access file... to access it via Code or is their any alter-native?? Do i need any Driver to do this ... i m able to access a Ms-access via JDBC but cant find the file wen
Display both image and data into Swing JTable
Display both image and data into Swing JTable  How To Display both image and data into Swing JTable which is retrieved from MySQL database
jtable with table headers - Swing AWT
jtable with table headers  give me java code to create jtable with table headers and by which i can scroll jtable and can retrieve height and width of the table
JTABLE IS NOT RETIVING DATE FROM MS ACCESS........PLEZ PLEZ PLEZ HELP!!!!!!
JTABLE IS NOT RETIVING DATE FROM MS ACCESS   PLEZ help me to retrive date from access to jtable....... import java.awt.BorderLayout; import... connection; private JTable table; private Object currentRow; public
applet connected to table in MS Access database
applet connected to table in MS Access database   i have connected my java code with the MS access database and this is my code, can anyone tell me how to show the table in an applet...pls import java.sql.
how to access the MS ACCESS database with java
how to access the MS ACCESS database with java   how to access the MS ACCESS database with java how can we insert,delete,update,search records of ms access with java   Java MS Access database connectivity Follow
java to MS Access conectivity - Swing AWT
java to MS Access conectivity  give me source code to stored... database on the ACCESS.  Hi Friend, Follow these steps: 1. Open...(ODBC) 2. Open User DSN tab 3. Add a user DSN 4. Select Microsoft Access Driver
how to insert values from jsp into ms access
how to insert values from jsp into ms access   how to insert values using jsp into ms access database
ms access
ms access  how to delete the autonumber from ms access using java delete code
display dinamic data in JTable - Swing AWT
display dinamic data in JTable  Hi, I need some help to development... and to read data in each files of this directory and to display it in one JTable... in this directory now i want to display the data of each files
how to access the MS ACCESS database with java - Java Beginners
how to access the MS ACCESS database with java  how can we insert,delete,update,search records of ms access with java
Ms Access
Ms Access   How to get query for Primary key from MsAccess?   SELECT column_name FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE table_name..._USAGE WHERE table_name = 'data'; In the above query, data is our table name
how to create a header in jtable using java swing
how to create a header in jtable using java swing  how to create a header in jtable using java swing   d
how to connect to MS access database in JSP?
how to connect to MS access database in JSP?  how to connect to MS access database in JSP? Any seetings/drivers need to be set or installed before it? Please tell what needs to be done after creating a table with an example
MS access
MS access  how do i access my Ms-Access file placed in the same jar file where my application code/class file r present??? Want to access it via Code. Can anyone help me ? Please give reply urgent...   give me reply
Jdbc MS-Access question
Jdbc MS-Access question  How to delete records from the three table in MS-Access? They are in relationship with each other regarding to data field
Jdbc MS-Access question
Jdbc MS-Access question  How to delete records from the three table in MS-Access? They are in relationship with each other regarding to data field
Select Employee and display data from access database in a jtable
Select Employee and display data from access database in a jtable  I... name of the customer is stored in a access database. Below is how it should... a employee's name from a comboBox and the jtable will be filled with all
ms access
and password" from my ms access............and detail in register(table in my ms... "username and password" from my ms access............and detail in register(table in my ms access) need to display values in jsp .............please help me
ms access
and password" from my ms access............and detail in register(table in my ms... "username and password" from my ms access............and detail in register(table in my ms access) need to display values in jsp .............please help me
ms access
and password" from my ms access............and detail in register(table in my ms... "username and password" from my ms access............and detail in register(table in my ms access) need to display values in jsp .............please help me
ms access
and password" from my ms access............and detail in register(table in my ms... "username and password" from my ms access............and detail in register(table in my ms access) need to display values in jsp .............please help me
MS-Access
MS-Access  I am trying to upload a image to ms-acess using jsp,and my...: [Microsoft][ODBC Microsoft Access Driver]COUNT field incorrect ".I think i set wrong datatype for table column in which my image going to be saved.I set
java swing (jtable)
java swing (jtable)  hii..how to get values of a particular record in jtable from ms access database using java swing in netbeans..?? please help... from database and display it in jtable. import java.awt.*; import java.sql.
How To Connect MS ACCESS 2003 Database in C Program with Graphics.
How To Connect MS ACCESS 2003 Database in C Program with Graphics.  How To Connect MS ACCESS 2003 Database in C Program with Graphics
display data from a table in Access Database in a HTML page
display data from a table in Access Database in a HTML page  how to display data from a table in Access Database in a HTML page in a Java Program
how to sort the text file and display it in jtable
how to sort the text file and display it in jtable   my text file... ctgaggactcctcg i want to display the lines started with ">" symbol to be displayed in jtable and sequence like "CGGGAATTAA..." in jtextarea in netbeans . pls suggest
MS ACCESS
MS ACCESS  i have done : Insert form data into MS database...-> data sources. 2)Click Add button and select the driver Microsoft Access...) Restart your server and run your jsp/servlet code and created a table
MS ACCESS
MS ACCESS  i have done : Insert form data into MS database...-> data sources. 2)Click Add button and select the driver Microsoft Access...) Restart your server and run your jsp/servlet code and created a table
MS ACCESS
MS ACCESS  i have done : Insert form data into MS database Follow...-> data sources. 2)Click Add button and select the driver Microsoft Access...) Restart your server and run your jsp/servlet code and created a table
how to send emails to many using jsp by connecting to ms access dabase.
how to send emails to many using jsp by connecting to ms access dabase.  Hi. I am trying to send multiple emails and the email ids are stored in a table in a msaccess database.I am using jsp for this.And finally there should
How to store JComboBox selected Item into Ms Access Database - Java Beginners
How to store JComboBox selected Item into Ms Access Database  How to store JComboBox selected Item into Ms Access Database.  Hi Friend...(); } public SwingFrame(){ JFrame f = new JFrame("Frame in Java Swing
how to use stringtokenizer on table? and display in table format.
display result in row format  how to use stringtokenizer on table? and display in table format
J2ME connectivity to ms access
J2ME connectivity to ms access  How to establish client server connectivity to access ms access database on the server side? I have made the odbc connection. Plz help me in the coding part.. Dont know how to start
how to use stringtokenizer on table? and display in table format.
how to use stringtokenizer on table? and display in table format.  table is retrieved from mysql database and each row contains data like(java,c,c++,.net
How to search the table name in MS SQL Database 2005 from application
How to search the table name in MS SQL Database 2005 from application  How to search the table name in MS SQL Database 2005 from application from our helpdesk application? application might be in html
MS Access` - IDE Questions
MS Access`  hello sir, how to configure MS Access database in Net Beans5.5... and i have a doubt, where should we run the below code...either in IDE or in any editor like EDITPLUS. waitin for your reply.... thank you
How to Open Picture From M.S. Access Database using Java Servlet ?
How to Open Picture From M.S. Access Database using Java Servlet ?  Hi all my Friends I have below code which insert a picture into M.S. Access Database But i m still not able to open this picture through Java using M.S. Access
how to connect java with ms access using odbc in eclipse
how to connect java with ms access using odbc in eclipse  import java.sql.*; class AccessDatabase{ public static void main(String[] args... Access Driver (*.accdb)};DBQ=student.accdb","",""); Connection con
link hibernate to MS ACCESS database
link hibernate to MS ACCESS database  how to link hibernate to ms access database instead of sql database
Swing JTable which is retrieved from MySQL
Swing JTable which is retrieved from MySQL  How To Display both image and data into Swing JTable which is retrieved from MySQL database
How to delete and update from Jtable cell in swing app
How to delete and update from Jtable cell in swing app  Hii Sir, I am developing a swing app for adding,updating and deleting from jtable... the custom DefaultTableModel static JTable table = new JTable(dTableModel); public
MS Access` - JDBC
MS Access`  Hello Sir, Thank you very much for your valuable information. Actually i am doin a project to generate Hall tickets.So, I need to insert image into MS Access Database. Now the task is how to retrieve the image
JTable - Swing AWT
JTable  Hi Deepak, i want to display the Jtable data... how could i show jtable data on the console. Thanks, Prashant   Hi...); JTable table = new JTable(new String[][] { {"A", "Delhi"}, {"B", "Mumbai
How to create and Attach MS Access Reports and Crystal Reorts in Java. - Java Beginners
How to create and Attach MS Access Reports and Crystal Reorts in Java.  How to create and Attach MS Access Reports and Crystal Reorts in Java WITH MS Access 2007 Database, plz Help Me Sir
 

 

 

DMCA.com