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



Home Answers Viewqa Java-Beginners how to use views

Have Programming Question? Ask it here!
 
 
 


Barughok
how to use views
1 Answer(s)      4 years and 10 months ago
Posted in : Java Beginners



Advertisement
View Answers

October 29, 2009 at 3:42 PM


Hi Friend,

We have retrieved the value from the database and show it in Swing table.

import javax.swing.*;
import javax.swing.table.*;

public class JTableDatabase extends JFrame{
public JTableDatabase() {
Vector columnNames = new Vector();
Vector data = new Vector();

try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection connect =DriverManager.getConnection("jdbc:odbc:access");

String sql = "Select * from data";
Statement stmt = connect.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);

JScrollPane scrollPane = new JScrollPane( table );
getContentPane().add( scrollPane );

JPanel buttonPanel = new JPanel();
getContentPane().add( buttonPanel, BorderLayout.SOUTH );
}
public static void main(String[] args)
{
JTableDatabase frame = new JTableDatabase();
frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
frame.pack();
frame.setVisible(true);
}
}

Thanks


Related Tutorials/Questions & Answers:
how to use views - Java Beginners
how to use views  how do i retrive data from a database and display it gui  Hi Friend, We have retrieved the value from the database and show it in Swing table. import javax.swing.*; import javax.swing.table.
how to use dirivers - JDBC
how to use dirivers  i try connecting to a database with this code but i get this ClassNotFoundException, already i have added the path to the connector to my classpath variable. here is the code; import java.sql.Connection
Advertisements
how to use - EJB
how to use  I am buiding a Shopping cart and i want to fetch image and its product id from the database(MySql) and fetching of image should be done by JPA
how to use a session.removeAttribute - JSP-Servlet
how to use a session.removeAttribute  Dear Sir, I am... help me how to use a correct method removeAttribut()..I am sending some of my code... a same previous matter. so i use a removeAttribute method ,den first time it works
how to use update - Java Beginners
how to use update  Hi all, your all code is perfect thanks. I have one table emp ID,emp name,view,modify and delete. emp_ide_name have taken from database but view modify and delete is link if user click modify data
HOW TO USE REQUEST DISPATCHER - Servlet Interview Questions
HOW TO USE REQUEST DISPATCHER  PLEASE USE A BUSINESS CODES TO EXPLAIN HOW TO USE REQUEST DISPATCHER, SESSION MANAGEMENT AND URL REWRITING. AND USE MSSQL DATABASE TO SAVE THE DATA THANKS FOR YOUR SOLUTION IN ADVANCE
How to use find method in Java - Java Beginners
How to use find method in Java  Hello, I want to write a class... properties. How can I do this? I was thinking, maybe get child objects of the browser class, then somehow parse through the class's objects/sub-objects, and use find
how to use float datatype in mysql? - SQL
how to use float datatype in mysql?  how to use float datatype in mysql?  hi Chitra this code help u CREATE TABLE `paging` ( `Id` float(10,2) NOT NULL default '0.00', `name` varchar(255) default NULL
how to use iframe in jsp - JSP-Servlet
how to use iframe in jsp  Hi, i am using a jsp page in whic records from database are shown in a table in one of the column i am showing all error links which point to error. jsp an another jsp when i click the link a new page
how to use toString method? - Java Beginners
how to use toString method?  i'm a new student, and learn with java. How to create a class named Employee with name and salary. Make a class... accessibility and methods with public accessibility) how to create the program
how to use MessageResource msgResorce = getResource in jsp - JSP-Servlet
how to use MessageResource msgResorce = getResource in jsp  How to how to use MessageResource msgResorce = getResource in jsp, but it is easily used in Axtion class
How to use update and reset method of CRC32
How to use update and reset method of CRC32.In this tutorial, we will discuss about the update() and reset() method of CRC32 class. The CRC32 class... in  java.util.zip package .  In this example, you will see how
Web Service - Which files we have to give to client and how they will use that
Web Service - Which files we have to give to client and how they will use.... 2) In client side how they will use that, and how they call method from... and have to use it, how we call this in jsp/servlet 3) Which type of response we
how do i use sql like query in my jsp page
how do i use sql like query in my jsp page  how do i use sql like query in my jsp page   Hi Friend, Try the following code: <%@ page import="java.sql.*"%> <% Class.forName("sun.jdbc.odbc.JdbcOdbcDriver
how to use javascript drag and drop files upload - Ajax
how to use javascript drag and drop files upload  Hi,Sir Please, I would like to upload multiple files using javascript with drag and drop style.I have asked to you similar problem recently.You answer to me to use java applet
How to use Arraylist object in <s:dobleselect> .... struts 2? - Struts
How to use Arraylist object in .... struts 2?  Hi Members, I saw the example of tag in roseindia, its very useful. But I have to use my ArrayList object with that tag. Im retrieving the values for arraylist object from
Java zip package - Learn how to use java zip package.
of java library. We will also learn how to use the zip API to create and read... Here is the list of more use of java.util.zip package, these examples will show you how you can create zip files of one more files or directories. Let's
use forms.
use forms.  How do I use forms
Use of setComment and getComment of ZipEntry.
Use of setComment and getComment of ZipEntry. In this tutorial, we will see the use of setComment and getComment method of ZipEntry  class. The ZipEntry class is used show available entries in a ZIP file. The ZipEntry class is 
Use Java Bean In Servlets
Use Java Bean In Servlets In this you will learn how to use Java Bean in Servlets. For this purpose, we have created a Bean named 'Person' and defined three variables with their setters and getters. Then we have created an object
Use char variable as integer
Description: Here in this example you will see how a char variable works like a integer. The char variable works with pre and post increment operators. Code: public class CharInt {   
the use of ForwardAction
the use of ForwardAction  What is the use of ForwardAction
Use of jQuery
Use of jQuery  What is the use of jQuery?   Hi, jQuery is JavaScript Ajax library. Developer is using it to create rich internet applications. Read at jQuery Tutorial. Thanks
use of jquery
use of jquery  what is a jquery? what is the evalution of jquery?   Hello Friend, Please visit the following link: JQuery Tutorials Thanks
Use of Comment Function in PHP
Use of Comments Function PHP Sometimes we need to hide some text in a program... generally use for putting important information of variables, functions... need to use your coding, it is also useful if you are working alone, comments
use tables to structure forms
use tables to structure forms  How can I use tables to structure forms
use tables to structure forms
use tables to structure forms  How can I use tables to structure forms
Java Use cases
Java Use cases  What are use cases
What is the use of DESC in SQL?
What is the use of DESC in SQL?  What is the use of DESC in SQL
ShortBuffer in java, Use of isDirect() method of ShortBuffer class in java.
Use of isDirect() method of ShortBuffer class in java. In this tutorial, we will check short buffer is direct or not. If direct memory is allocated their memory address is fixed for the lifetime of the buffer. ShortBuffer
ShortBuffer in java, Use of equals() method of ShortBuffer class in java.
Use of equals() method of ShortBuffer class in java.  In this tutorial, we will check short buffer is equal to another buffer or not. ShortBuffer API: The java.nio.ShortBuffer class extends java.nio.Buffer class
Use of CASCADE CONSTRAINTS
Use of CASCADE CONSTRAINTS  hii, What is the use of CASCADE CONSTRAINTS?   hello,, CASCADE CONSTRAINTS describes about the parent-child relationship between tables
What is the use of DBCC commands?
What is the use of DBCC commands?  What is the use of DBCC commands?   Hi, DBCC stands for database consistency checker. We use these commands to check the consistency of the databases, i.e., maintenance, validation
use of plugins - Swing AWT
use of plugins  hi dear i m making a project on java swing .i needed a plugins for search buttons........  https://swingexplorer.dev.java.net/tips.html Thanks
use of ejb - EJB
use of ejb  what is the use of ejb??  Hi friend, Some points to be remember for using ejb : * Applications developed by using the enterprise beans deal with a variety of clients, simply by writing few lines
Use javascript loops..
Use javascript loops..  Write a JavaScript code to find a number of unique letters in string. (Eg. if keyword is Tajmahal, Tajmahal count will be '5' , it only takes these letters T,j,m,h,l , not taken the letter a because
java use dll file - Java Beginners
java use dll file  how to execute dll file in java
Use of Connection Pooling - JSP-Servlet
(); System.out.println(c); } } my problem is how can i use this bean...Use of Connection Pooling  Dear Friends i want to use connection... object, use this in ur application Thanks Rajanikant
Use of isReadOnly() method in java.
Use of isReadOnly() method in java. In this tutorial, we will see how to use of isReadOnly method in java. IntBuffer API : The java.nio.IntBuffer class extends java.nio.Buffer class. It provides the following methods: Return
Use of yum install linux mysql php command on Linux box
is ready and you can use for testing or deploying your applications. User the following command to start apache: service httpd start Use following command
Where to use ServiceImpl - Development process
Where to use ServiceImpl  Hi, In j2ee project where we can use service and ServiceImpl files. Plz explain about that .Thanks Prakash
adding data to the database with the use of jtable - Java Beginners
adding data to the database with the use of jtable  how can i add data to the database with the use of jtable. and also can able to view the records in the database in the table.. tnx :G
adding data to the database with the use of jtable - Java Beginners
adding data to the database with the use of jtable  how can i add data to the database with the use of jtable. and also can able to view the records in the database in the table.. tnx :G
Describe the use of PL/SQL tables
Describe the use of PL/SQL tables  Describe the use of PL/SQL tables   Hi, PL/SQL tables are scalar arrays that can be referenced by a binary integer. They can be used to hold values for use in later queries
Use of Throwable Class
Use of Throwable Class Throwable class is the super class of all the exceptional class and error class. Only objects of this class can be thrown & caught and handled by try-catch blocks. In java you can throw exception Object which
Use of rewind method in java.
Use of rewind method in java.       In this tutorial, we will explain the use of rewind() method of Buffer class. The ByteBuffer class is a container for handling data.The ByteBuffer class
Push View Controller - Example
between two views. In Cocoa, we have several instance methods which is used...... But when we use "pushViewController" we means to show the next top stack item..., you'll get following output. In the next example i will show you how
why to use hibernet vs jdbc
why to use hibernet vs jdbc  plz send me the reply   Hi... specific 2) Hibernate is a set of Objects so there is no use of sql whereas in JDBC there is a use of SQL. 3) As Hibernate Supports two level of cache, you
Confermation for use of API - Java Beginners
Confermation for use of API  HI ! I am new here. I am making an application for wireless communication between mobile and pc. Let me know which api I have to use at J2SE side. I will be very thankful to you. Regards
 

 

 

DMCA.com