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



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Yogesh Gaikwad
table
1 Answer(s)      3 years and 10 months ago
Posted in : Java Beginners


Hi.. I am doing a project on Inventory Management System for which i created the user interfaces.. I have a user interface in which i have used JTables.. Now my problem is I dont know how to show the Jtable which takes input from oracle table(my database table..) This is a very important table of my project.. Please help me out..


Advertisement
View Answers

December 21, 2010 at 10:38 AM


Hi Friend,

Try the following code:

import java.io.*;
import java.awt.*;
import java.sql.*;
import java.util.*;
import javax.swing.*;

class JTableDatabase extends JFrame{
    ResultSet rs;
    JTableDatabase(){
    final Vector columnNames = new Vector();
        final Vector data = new Vector();
      JPanel panel=new JPanel();
      try{
    Class.forName("com.mysql.jdbc.Driver");
     Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
        Statement st = con.createStatement();
        ResultSet rs= st.executeQuery("Select * from employee");
    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 );
}
}
catch(Exception e){}
JTable table = new JTable(data, columnNames);
JScrollPane scrollPane = new JScrollPane(table);
panel.add(scrollPane);
add(panel);
}
 public static void main(String arg[])
  {
    try
    {
    JTableDatabase frame=new JTableDatabase();
    frame.setSize(550,200);
    frame.setVisible(true);
    }
  catch(Exception e)
    {}
  }
}

Thanks



Related Tutorials/Questions & Answers:
table
table  multiplicatyion table
TABLE
TABLE   Why doesn't <TABLE WIDTH="100%"> use the full browser width
Advertisements
Table
Table  How i generate table in showMessageDialog. I want that i creat a table and run in showMessageDialogeprint("cprint("code sample");ode sample
Table
Table  How i generate table in showMessageDialog. I want to creat a table and run in showMessageDialoge. Pl make a table programe which run..., JOptionpane, Integer.parseInt. Please use only these above methods to make table
Table
Table  How I generate table in showMessageDialog. E.g 3X1=3 3X2=6 3X3=9print("code sample
Table
Table  How i generate table in JOptionpane.showMessageDialog... advance coding but i want u make the table using JOptionpane.showMessageDialog, import.javax.swing int Integer.parseInt(). Thats my limit. Pl generata a table
table
table  Hi..I have a list of links which links to a table in the same page.If I click first link the table is displayed at the top, likewise if i click the last link the table is displayed at the last,i dont know how to set
table
input from oracle table(my database table..) This is a very important table of my
table?
table?  Hi, how could i make a table in javascript, which would look like this: AA CODON Number /1000 Fraction .. (this row... can't figure out, how to construct a table,with two fixed columns, one that reads
Table
Table  Why u dont understand sir?? I want to make a table program which generate a table on showMessageDialog. I have learnt these methods until now... methods to be used. Write a table program which use only and only these above methods
Table
Table  How i create table on showMessageDialog using JOptionpane and Integer.parseInt. No other method to use. Pl make a program which generate 5X1=5 5X2=10 5X3=15   Hi Friend, Try this: import javax.swing.*; import
table in java
table in java  please l want to make table and insert by user
HEAP table
HEAP table  hiii, What is HEAP table?   hello, This type of table is stored in the memory. Speed of execution of this table is very commendable
table header
table header  how set the header to the TableModel
center a table
center a table  How do I center a table
table in java
table in java  Could any one make compiler in java please reply me
table in java
table in java  Could any one make compiler in java please reply me
SQLite Table
SQLite Table  how to create a table in sqlite xcode with a fix number of items
table in java
table in java  Could any one make compiler in java please reply me
Multiplication table
Design and develop Multiplication table in Net beans  Design and develop a program that will print a multiplication table. The program should: Ask... table.   import java.util.Scanner; class Multiplication { public static
Hash table
Hash table  Hi guys.. I have question about hash table How to implement a hash table of English words? with these methods ï??· A method put(s), which adds the string s to the table, if it is not already there (a bit
multipications table
.. Table (decide if this is HTML or JSP) Table shows the multipications table up... will be: 1 2 3 2 4 6 3 6 9 Also, add a button to Table so that pressing this button will make the table disappear. helppppp don't know were to begin plea
Multiplication table
Multiplication table Net Beans  Using Net beans Design and develop... for ending number than Display that particular multiplication table   ...(String args[]) { int n; System.out.print("Enter the number whose table
Table Creation
Table Creation  hi! I want a table which looks like following can... to make such table? plz help.........  ...","Oct","Nov","Dec" }; JTable table = new JTable(rowData, columnNames
jsf table
a table named as customer. customer table has following columns : customerid(varchar... table in this index.jsp file.this jsf file should be able to retrieve the data from... the table customer.   Hello Friend, Please visit the following link
Multiplication table
number than Display that particular multiplication table   import...[]) { int n; System.out.print("Enter the number whose table is to be displayed
Table Creation
Table Creation  create the table for the following fields.its very urgent for me.plz help me S.No,Category( From the home page),Name of the Candidate( After registering and after selecting the category),Age,Title of the project
Drop Table
Drop Table       Drop Table in SQL get rid of an object or table from the database. Using a drop Query get rid of all the rows deleted from the table and the structure is removed
Adding a flex table in another flex table column
Adding a flex table in another flex table column  how to add a flex table in another flex table column
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
mysql select into table from another table example
mysql select into table from another table example  Can you suggest the correct example of select into table from another table example in MySQL... from one table into another table. Check the example at MySQLselect into new
 

 

 

DMCA.com