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



Home Answers Viewqa Java-Beginners java swing (jtable)
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


java
java swing (jtable)
1 Answer(s)      2 years ago
Posted in : Java Beginners


hii..how to get values of a particular record in jtable from ms access database using java swing in netbeans..?? please help..its urgent..


Advertisement
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 {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
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(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);
}
}


Related Tutorials/Questions & Answers:
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.
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
Advertisements
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
focustraversalpolicy taborder Swing JTable
focustraversalpolicy taborder Swing JTable  how to make a focustraversalpolicy that can make the tab order to jump over one column
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
JTable - Cell selection - Swing AWT
information. http://www.roseindia.net/java/example/java/swing/ 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
://www.roseindia.net/java/example/java/swing/ 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
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
JTABLE OF JAVA
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
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-Java
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 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
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
about Java JTable, just click http:/www.roseindia.net/java/example/java/swing... Java JTable       JComponent.component is more flexible Java Swing component that allows the user
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
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
JAVA DATABASE CONNECTION WITH JTABLE  HOw To Load Database Contents From Access Database to JTable without using Vector
update a JTable - Java Beginners
://www.roseindia.net/java/example/java/swing/ 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-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
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 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
JTable - Java Beginners
the following links: http://www.roseindia.net/java/example/java/swing/CellGap.shtml http://www.roseindia.net/java/example/java/swing...(); stat3.close(); JTable table = new JTable(data, columnNames
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
 

 

 

DMCA.com