Home Answers Viewqa Swing-AWT Need source code

 
 


Terrance
Need source code
1 Answer(s)      3 years and 4 months ago
Posted in : Swing AWT

Hai friends,
How can I, view all the datas from the mysql database table in the jframe........
View Answers

January 19, 2010 at 10:20 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 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);
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 Pages:
Need source code - Swing AWT
Need source code  Hai, I need a source code for developing the project, title is "Face Recognition" and the backend as My-sql.... Thanks & Regards
Need source code - Swing AWT
Need source code  Hai, I need a idea and code for developing the project "Face Recognition" with the backend as My-sql.... Thanks & Regards
Need Java Source Code - JDBC
Need Java Source Code  I have a textfield for EmployeeId in which the Id, for eg: "E001" has to be generated automatically when ever i click... be implemented.  Hi friend, Please send me code because your posted
Need source code - Swing AWT
Need source code  Hai friends, How can I, view all the datas from the mysql database table in the jframe........  Hi Friend, Try the following code: import java.awt.*; import java.sql.*; import
Need source code - Swing AWT
Need source code  Hai, In java swing, How can upload and retrieve the images from the mysql database?   Hi Friend, To upload and insert image in database, try the following code: import java.sql.*; import
source code
source code  hellow!i am developing a web portal in which i need to set dialy,weekly,monthly reminers so please give me source code in jsp
i need the source code to generate id in jsp
i need the source code to generate id in jsp  hai,i need the source code for generate id...which is i need to generate the new id from the maximum... of generate ids each should have some range...plz give the source code in jsp with ms
in need od source code - Development process
in need od source code  i am in the process of developing..., module, activity, and no of hours worked from week start to weekend... i need a source code for creating the front end, and for database, and linking from front end
i need attendce management system source code in java
i need attendce management system source code in java  i need attendance management system source code in java
source code in jsp
source code in jsp  i need the source code for online payment in jsp
request for java source code
request for java source code  I need source code for graphical password using cued-click points enabled with sound signature in java and oracle 9i as soon as possible... Plz send to my mail
source code in jsp
source code in jsp  sir...i need the code for inserting images into the product catalog page and code to display it to the customers when they login to site..pls help me
source code - JSP-Servlet
source code  i need source code for client server application in jsp to access multiple clients   Hi Friend, Please visit the following link: http://www.roseindia.net/jsp/ Here you will get lot of examples
Need a JSP CODE
Need a JSP CODE  *Hi I need JSP source code for selling products which are in database.. please can any one help me ..URGENT* Thank You
need code - Java Beginners
need code   i want to take the html coding. if user give a input html.... (view -> source) . how it is possible in java.  Hi Friend, Here we are sending you a sample code which will be helpful to you. import java.io.
source code program - Java Beginners
source code program  I need the source code for a program that converts temperatures from celsius to fahrenheit and vice versa, as well as converting kilometers to miles and vice versa using Java "classes".  Hi
Source Code cls - Java Beginners
Source Code cls   Dear RoseIndia Team, Thanks for your prompt reply to my question about alternate to cls of dos on command line source code. I... a oneliner (i.e cls) this would give us the same result. No need of compiling/running
calendra.css source code - Java Beginners
calendra.css source code  hello i need the source code... and year are getting displayed  Hi Friend, Try the following code...; cursor: pointer; } You can also download the code from the following link
shoping items billng source code
shoping items billng source code  Hi, I am doing a project on invoice making, I am unable to make code for the billing, I have a n jsp page "invc.jsp", here in this page i need to get the items from the data base with respect
shoping items billng source code
shoping items billng source code  Hi, I am doing a project on invoice making, I am unable to make code for the billing, I have a n jsp page "invc.jsp", here in this page i need to get the items from the data base with respect
shoping items billng source code
shoping items billng source code  Hi, I am doing a project on invoice making, I am unable to make code for the billing, I have a n jsp page "invc.jsp", here in this page i need to get the items from the data base with respect
shoping items billng source code
shoping items billng source code  Hi, I am doing a project on invoice making, I am unable to make code for the billing, I have a n jsp page "invc.jsp", here in this page i need to get the items from the data base with respect
shoping items billng source code
shoping items billng source code  Hi, I am doing a project on invoice making, I am unable to make code for the billing, I have a n jsp page "invc.jsp", here in this page i need to get the items from the data base with respect
source
source  how to pass the morethan one fields from one page to another page in struts1.2? i am using tchnologies are struts1.2 oracle 10g myecllipse 8.6 so please post the exact source code to support the above technologies
retail invoice and billing source code in struts
retail invoice and billing source code in struts  Hi. I need source code for "retail invoice and billing source code in struts", Please help me in doing so. Please It's important and urgent
source code
source code  how to get the fields from one page to another page in struts by using JSTL
need of code
need of code  howto convert greyscale image to binary image in java
source code
source code  how to use nested for to print char in java language?   Hello Friend, Try the following code: class UseNestedLoops{ public static void main(String[] args){ char[][] letters = { {'A', 'B'}, {'C','D
need code
need code  Create Vehicle having following attributes: Vehicle No., Model, Manufacturer and Color. Create truck which has the following additional... is the required code: import java.util.*; class Vehicle { int
need code
need code  Create Vehicle having following attributes: Vehicle No., Model, Manufacturer and Color. Create truck which has the following additional... is the required code: import java.util.*; class Vehicle { int
need code
need code  Create Vehicle having following attributes: Vehicle No., Model, Manufacturer and Color. Create truck which has the following additional... is the required code: import java.util.*; class Vehicle { int
source code - Java Server Faces Questions
source code  hi deepak i need a program's source code in javascript which will response to mouse event. with description of onmouseout nd onmouseover... waiting 4 ur reply   Hi friend, Code for onmouseout nd
source code for the following question
source code for the following question  source code for the fuzzy c-means
Java source code
Java source code  How are Java source code files named
Hiding Source Code - WebSevices
Hiding Source Code  Is there any way to prevent viewing source code in browser
java/j2ee source code
java/j2ee source code  java/j2ee source code for online food purchasing service with my sql database
java source code
java source code  java source code to create mail server using struts2
source code - Swing AWT
source code  source code for a program to shutdown, restart, log off the pc after clicking jbutton on jpanel or a jframe by user. thanks in advance
source code security
source code security  how to obfuscate the code? please answer as soon as possible
Source Code - Java Beginners
Source Code  What do I have to add to my original code to make it work
source code in jsp
source code in jsp  how to insert multiple images in jsp page of product catalog
source code - JSP-Servlet
source code for webcam chat application  I want source code for this webcam chat application. I like the concept of XAWARE ORG regarding web cam chat. So that i want the code through this XAWARE only.pls send the code as soon
Java Source code
Java Source Code for text chat application using jsp and servlets  Code for text chat application using jsp and servlets
source code - JSP-Servlet
source code  please i want source code for online examination project (web technologies)  Hi Friend, Send some details of your project. Thanks
source code - EJB
-of-StatelessBean.shtml", it is written that "The source code for CalculatorBean is in ?net... Simply u download the complete source code from download link...source code   I am new to EJB. I am reading tutorial from http
reg : the want of source code
reg : the want of source code  Front End -JAVA Back End - MS Access Hello Sir, I want College Student Admission Project in Java with Source code...) Available Seats and etc. plz Give Me Full Source code with Database
source code - JDBC
source code  give me a source code to connect from java to mysql that can run on eclipsed i am using mysql-essential-5.0.41-win32_1. also give procedure how can i connect from eclipsed to mysql-essential-5.0.41-win32_1. thanks
Project source code
Project source code  i want source code for contact finder just like facebook provides or linkedin website on der home page just similar to dat...i m working on jsp project ..its a web based project which stores information
Need sample code
Need sample code  Need code for graph which shows the performance comparission of aprior algorithm and coherent rule algorithm.plz can any one help me i need in a week
need JSP Code.
need JSP Code.  **Hi I need JSP code for selling Products which are in Database. Please can any one help for this.URGENT... Thank You..! Abhijeet

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.