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:access"); String sql = "Select * from data"; 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) ); } 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:
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
Java JTable Question or Datagrid - Java Beginners
Java JTableQuestion or Datagrid Hello Sir How I can Display data in to JTable or grid which is Stored in MS Access Databse with Add,Update,Deletetion of Records.
plz Help Me
Hi Friend,
Please go through
JTable
JTable Values to be displayed in JTextfield when Clicked on JTable Cells
JTable
JTable i want to delete record from JTable using a MenuItem DELETE. and values of JTable are fetched from database....please reply soon
JTable 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
JTable need to add values to a JTable having 4 coloumns ,2 of them are comboboxes
search filter and JTable
my question is:
how can i make search data in JTable of java?
i wan to search records in table or textfield but the data display in JTable.
Note: i dont...","Contact No","Email"};
JTable table=new JTable(data,labels
JTable
JTable Hello, i cannot display data from my table in the database to the cells of my JTable. please help me
jtable
jtable how to get the values from database into jtable and also add a checkbox into it and then when selected the checkbox it should again insert into database the selected chewckbox.plzz help
jtable
jtable hi
Sir
i am working netbeans IDE,I have a jtable when i insert values in jtable
then i am unable to print all inserted values,For eg if i insert 1,2,3,4,5,6,7,8 values
then , i am getting output
jtable
jtable hey i have build a form and i m also able to add data from database to jtable along with checkbox.the only problem is that if i select multiple checkboxes the data doesnt get inserted into new database and if only one
JTable
JTable Hi
I have problems in setting values to a cell in Jtable which is in a jFrame which implements TableModelListener which has a abstract method
tableChanged(TableModelEvent e) .
I'll be loading values from data base when
Shading Rows in JTable
the
shading rows in JTable. But, the question arises
what is shading?.
Shading... Shading Rows in JTable
You have learnt about the JTable components and its
Java question - Swing AWT
Java question I want to create two JTable in a frame. The data in one JTable will be shown as a result of a query i.e. the data in a resultset... JTable this row should be added in the second JTable and should be visible
jtable problem jtable problem how to make a cell text hypertext
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
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
Swings JTable
Swings JTable add values to JTable with four coloums,two of them are comboboxes
sum in JTable
sum in JTable how to calculate sum from JTable's one field like total
JTABLE Issue JTABLE Issue Hi Eveyone,
I am developing a small application on Swing-AWT. I have used JTABLE to show data. There is "input field" and "search... on basis of input data provided in input field. For JTABLE is on some other
jtable query jtable query I need a syntax...where i could fetch the whole data from the database once i click the cell in jtable...and that must be displayed in the nearby text field which i have set in the same frame
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
ABOUT Jtable
ABOUT Jtable My Project is Exsice Management in java swing Desktop Application.
I M Use Netbeans & Mysql .
How can retrive Data in Jtable from Mysql Database in Net Beans
jtable insert row swing jtable insert row swing How to insert and refresh row in JTable?
Inserting Rows in a JTable example
REPORT WITH JTABLE
(Exception e){}
JTable table = new JTable(data, columnNames);
JScrollPane scrollPane
JTable - JDBC
JTable
Hello.....
I have Jtable with four rows and columns and i have also entered some records in MsSql database. i want to increase Jtable's...
{
JFrame f;
JPanel p;
JLabel l;
JTextField tf;
JButton btn;
JTable tb
question question sir plz tell me what should i give in title box. just i want java program for the question typed in this area
question question sir plz tell me what should i give in title box. just i want java program for the question typed in this area
Question Question When there is an exception in my program how java runtime system handles
question
question dear sir/madam
my question is how to compare two text format in java..we are java beginners..so we need the complete source code for above mentioned question...we have to compare each and every word
question
question Dear sir
i had some typing mistake at previous question
so its my humble request to let me know the steps to start the tomcat6 under the tomcat directory
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 hold different components JTable hold different components create Jtable with two coloums,one coloumn is combobox and other normal
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
restrict jtable editing
restrict jtable editing How to restrict jtable from editing or JTable disable editing?
public class MyTableModel extends...){
return false;
}
}
Disabling User Edits in a JTable Component
question
question Gud morning sir,
I have asked u some question regarding jsp in saturaday for that i didnot find any answere in which u send me the some of the links.U have asked me the specify some details.
There is a entity name
Question? Question? My question is how to:
Add a menu bar to the program with a File menu.
In the File menu, add a submenu (JMenuItem) called About.
When the user clicks on the About menu item, display a JOptionPane message dialog
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
Regarding My 3rd Question in Java - Swing AWT
Regarding My 3rd Question in Java sir in Netbeans By default JTable Columns will appear Horizontal like
Title1 Title2 Title3 Title4
in below these our data will appear so my question that is there any method