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

Home Answers Viewqa Java-Beginners java swing (jtable)

Have Programming Question? Ask it here!

java swing (jtable)
1 Answer(s)      a year and 4 months ago
Posted in : Java Beginners to get values of a particular record in jtable from ms access database using java swing in netbeans..?? please help..its urgent..

View Answers

December 17, 2012 at 5:29 PM

Here is an example that retrieves the particular record from database and display it in jtable.

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 {
Connection con = DriverManager.getConnection("jdbc:odbc:roseindia");
String sql = "Select * from data from id=1";
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) );
if( {
Vector row = new Vector(columns);
for (int i = 1; i <= columns; i++){
row.addElement( rs.getObject(i) );
data.addElement( row );
catch(Exception e){
JTable table = new JTable(data, columnNames);
TableColumn col;
for (int i = 0; i < table.getColumnCount(); i++) {
col = table.getColumnModel().getColumn(i);
JScrollPane scrollPane = new JScrollPane( table );
p.add( scrollPane );
JFrame f=new JFrame();

Related Tutorials/Questions & Answers:
java swing (jtable)
java swing (jtable) 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.
jtable in java swing
jtable in java swing  hai friends... i am creating 1 GUI having 1 table, that table contain 3 fields(columns) and 10 rows.. user can enter values in the first 2 columns. The 3rd column is the concatenation of first 2 column
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
jtable insert row swing
jtable insert row swing  How to insert and refresh row in JTable?   Inserting Rows in a JTable example
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
JTable - Swing AWT
JTable row selection event   Hi, it will be great if someone can share an example of row selection event in JTable
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...*; public class JTableToConsole extends JFrame { public Object GetData(JTable
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 - Swing AWT
JTable  Hi Deepak, i m facing a problem with jtable. i am able to display the values from the database into the jtable. but not able to modifying multiple cell values in a row. also i want to store those modified
problem with JTable - Swing AWT
to swings.i was having an assignment like i need to create a JTable... an action event such that if i check the checkbox outside the JTable,all the checkboxes inside the JTable should be checked. details: for creating JTable
focustraversalpolicy taborder Swing JTable
focustraversalpolicy taborder Swing JTable  how to make a focustraversalpolicy that can make the tab order to jump over one column
JTable - Cell selection - Swing AWT
information. Thanks. Amardeep...JTable - Cell selection  How to select a cell of a JTable when I... javax.swing.event.*; public class JTableDemo extends JFrame { JTable table
JTable Cell Validation? - Swing AWT
:// Thanks  it's not exactly...JTable Cell Validation?  hi there please i want a simple example of JTable with 3 columns Name,Number,Price and the first columns is string
JTABLE OF JAVA  i have a jtable in java,i have used checkbox in jtable. now i want to add(submit) only those records that i have checked by checkbox how? i want small example with coding
java jtable
java jtable  Hello Sir, I am developing a desktop application in which i have to display database records in jtable .now I want to read only... that in jtable. plz help me with the code
Jtable-Java  Hi all,I have a Jtable And i need to clear the data in the table .I only Need to remove the data in the table.not the rows.Please help me
Java swing: Export excel sheet data to JTable
Java swing: Export excel sheet data to JTable In this tutorial, you will learn how to read data from excel file and export it to JTable. In swing applications, sometimes, it is required to display the excel file data into the jtable
Java JTable
Java JTable  I am create one application. The application is same as MSExcel. but the content do not modify by others. I am refer the following link. link text That work fine. But i want display content in my datatbase. If i
Swings JTable numberic sorting - Swing AWT
Swings JTable numberic sorting  Hi , i am using jdk1.6 for my project and jdk1.6 is providing by default sorting of text column in JTable or suggestion for sorting of numberic column in JTable of Swings...Swings JTable numberic
Java JTable
about Java JTable, just click http:/ Java JTable       JComponent.component is more flexible Java Swing component that allows the user
JTable - Java Beginners
JTable search example  I've problem about JTable, i wan to search records when i types words in JTable cell,can u give the source code.I'm Beginner and i start begins learning java programming.Please send the example into my
JAVA DATABASE CONNECTION WITH JTABLE  HOw To Load Database Contents From Access Database to JTable without using Vector
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
JTable-Selecting a given cell - Swing AWT
JTable-Selecting a given cell  I tried the previous JTableDemo program but how to select a particular cell when i know the row,column number when button is clicked
update a JTable - Java Beginners
:// Thanks...update a JTable   how to update a JTable with Mysql data through user... in an updatable JTable You would create the table as follows: conn
Jtable with servlet - Java Beginners
Jtable with servlet   Actually I have embedded the html with servlet code in a java class. where user will enter the information in textboxes... time I want the JTable to display the record saved in the database,the JTable
JTable in java - Java Beginners
JTable in java  Sir , I have created an application with a JTable showing the records of an MS Access database table. On the same frame I have... given one , JTable table; ....... .... table.print(); Here the error
Creating a JTable Component
the simple JTable on the java swing frame with the help of some java methods. To create a JTable component, you need a java swing frame. The JTable based on the frame's... of JTable and it's components. JTable: The JTabel component is more flexible Java
JTable - Java Beginners
the following links:; stat3.close(); JTable table = new JTable(data, columnNames
Java: Adding Row in JTable
Java: Adding Row in JTable   how about if we already have the JTAble created earlier. And i just found nothing to get its DefaultTableModel, thus, I can't call insertRow() method. Is there any work around for this? I found
JTable   how to select a definite cell which containing a similar text containg to the one which the user entering from a jtable at runtime in java
Jtable Question - Java Beginners
Jtable Question  Hello Sir, I have Created Database in MS access 2007 ,I want show the table data in to Swing JTable, How I can Show it, plz Help...(); stmt.close(); } catch(Exception e){ System.out.println(e); } JTable table = new
JTable - Java Beginners
JTable  can we merge two cells of one row in jtable
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... is getting removed from the jtable but selected row is getting deleted from
Java JTable Question or Datagrid - Java Beginners
Java JTable Question or Datagrid  Hello Sir How I can Display data in to JTable or grid which is Stored in MS Access Databse with Add,Update... the following link:
Java - Swing AWT
Java  write a swing program to display the contents of a database in a JTable
java swing - Swing AWT
java swing  how i can insert multiple cive me exampleolumn and row in one JList in swing?plz g  Hi Friend, Please clarify your question. Thanks
JTable - Java Beginners
want my JTable on the panel. and i also want to increase height and width... back. thank you very much sir for your help. i am new to java and your help...); } res2.close(); stat3.close(); JTable table = new JTable(data
Java swing
Java swing  what are the root classes of all classes in swing
Java swing
Java swing  Does Swing contains any heavy weight component
java swing
java swing  view the book details using swing
JTable - Java Beginners
JTable Search Filter  Hi,i wanted to add a search filter in my JTable application.Thanks in Advance!!  i'means using database access,when...=============================================================================i press the enter button into JTable cell and focus
java swing
java swing  what is java swing   Swing is a principal GUI toolkit for the Java programming language. It is a part of the JFC (Java Foundation Classes), which is an API for providing a graphical user interface for Java
jtable combo - Java Beginners
jtable combo  i am using jtable (using defaulttablemodel) ,when i am click on a particular cell of jtable i want to display the combo box...); JTable table = new JTable(model); TableColumnModel tcm = table.getColumnModel
java swing
java swing  how to connect database with in grid view in java swing   Hi Friend, Please visit the following link: Grid view in java swing Thanks
JTable - Java Beginners
JTable  Hi, I have some problem with JTable. On show All button hit.... my problem is with Jtable, sometimes it is visible and sometimes it is not. when...(); JTable table = new JTable(data, columnNames); sp=new JScrollPane(table
java swing - Swing AWT
java swing  how to add image in JPanel in Swing?  Hi Friend, Try the following code: import java.awt.*; import java.awt.image....: Thanks
update a JTable - Java Beginners
update a JTable   i have tried your advice as how to update a JTable... main(String args[]) { JTable table; Connection con = null..."); ResultSetTableModel model = new ResultSetTableModel(rs); table = new JTable(model
Java swing
Java swing  Write a java swing program to calculate the age from given date of birth
java swing
java swing  add two integer variables and display the sum of them using java swing