jdbc and swing problem in netbeans

jdbc and swing problem in netbeans

i reteived the table from database in a jdbc program. next i want to do is place the table as it is in a jpanel.. i am using netbeans IDE can u tel me how to do that one?? urgent

View Answers

August 29, 2011 at 2:52 PM

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)
   {}
  }
}









Related Tutorials/Questions & Answers:
jdbc and swing problem in netbeans
jdbc and swing problem in netbeans  i reteived the table from database in a jdbc program. next i want to do is place the table as it is in a jpanel.. i am using netbeans IDE can u tel me how to do that one?? urgent
jdbc and swing problem in netbeans
jdbc and swing problem in netbeans  i reteived the table from database in a jdbc program. next i want to do is place the table as it is in a jpanel.. i am using netbeans IDE can u tel me how to do that one?? urgent
Advertisements
Java swing in NetBeans - Swing AWT
Java swing in NetBeans   thanks a lot sir for everything you answered for my last questions now sir i just have another 3 questions that is Q 1. i will specify a swing code for JTable using NETBEANS so would you tell me
java swing in netbeans
java swing in netbeans  how can create sub menu in java swing using netbeans?   Hi Friend, Try the following code: import javax.swing.*; public class CreateSubmenu { public static void main(final String args
Swing Problem on submission of button
Swing Problem on submission of button  How to close current frame (Frame1) and open a new frame (Frame2) already created and pass the data to frame2 from frame1 on the clicking of button in swing
oracle connectivity problem with netbeans
oracle connectivity problem with netbeans  sir I am using oracle window version +net bean6.8. jam trying to connect net bean to oracle. for this after adding new driver(ojdbc6.jar) in services tab I got connectivity with oracle
problem in jdbc connection
problem in jdbc connection  when i am trying to insert into apache derby databse using java in netbeans an exceprion is thrown at run time like this:- java.lang.ClassNotFoundException: org.apache.derby.jdbc.ClientDriver....what
problem in swing-awt
problem in swing-awt  I am doing project in core java and i am facing one problem. I have to add command prompt(terminal) to the fream at bottom but not getting the solution. So please help me. thanks and regards, Aakash
jdbc problem
jdbc problem   hi my name is mohit...i am making a project in java.......i have made this code in netbeans...i have already entered the values..."); con = DriverManager.getConnection("jdbc:odbc:mohit"); stmt
swing with jdbc - Swing AWT
have some problems with swing using jdbc. 1. the values entered in table are not stored in DB. 2. is there is any solution that uses jtable with JDBC? kindly...swing with jdbc  Hi, i m developing the desktop application using
struts 2 problem with netbeans - Struts
struts 2 problem with netbeans  i made 1 application in struts2 with netbeans but got one errror like There is no Action mapped for namespace... please give me acton mapping problem solution   Hi Friend, Please
Swing and AWT Problem - Swing AWT
Swing and AWT Problem  hi sir i have a problem i know from one Jframe we can send values to another Jframe. so in my project i have one fame containing three textfields CODE: String a=TNa.getText().toString(); String b
tooltip problem - Swing AWT
tooltip problem  Hi All, I am using SWT_AWT bridge in my code to embed swing components into SWT Composite. I am using a Swing JButton in SWT Composite. My problem is that I am unable to see the tooltip for this button even
coding problem in netbeans - Java Beginners
coding problem in netbeans  hi, i have just started programming in netbeans,i'm facing a problem in a java application i create a jframe class and jbutton and jtextfeild inside it now i have created another class c1
JDBC related Problem - JDBC
JDBC related Problem  Hey plz check out the following code... = "jdbc:odbc:" + ds; try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver... connectivity code ...... my problem is... that even after the successful
swing frame problem
swing frame problem  Hi All, I m creating a swing/awt based window application which will take some data from user and according to that data it will display some information from DB to user etc.. Now when I will create
Java Problem Steps - Swing AWT
Java Problem Steps  How to create a Jar File From the Dos prompt of a Swing program having two classes in the program with one is public class one of them
java,jdbc,netbeans
java,jdbc,netbeans  can you tell me the program which read multiple dbf files and then insert those dbf files data in msaccess automatically
swing text field problem
swing text field problem  I want to navigate the content of text field from one class to another and viceversa through button but when I am getting the text from first class I am getting null value.please help me..here
swing text field problem
swing text field problem  I want to navigate the content of text field from one class to another and viceversa through button but when I am getting the text from first class I am getting null value.please help me..here
problem with JTable - Swing AWT
problem with JTable  hi guys, i was a student and i am very new to swings.i was having an assignment like i need to create a JTable with checkboxes inside it.i do have another checkbox outside the Table.i need to write
SQL STATEMENT in JDBC in NETBEANS IDE
SQL STATEMENT in JDBC in NETBEANS IDE  Iam using NETBEANS IDE. Iam developing a bank application. Using JDBC in SERVLETS For the withdraw function, "bal" and "ano" are user inputs when i wrote like, st.executeQuery("UPDATE
jdbc oracle connectivity problem
jdbc oracle connectivity problem  Hi All, I am trying to connect my swing application to oracle DB . but class.forname is giving error. Please suggest me if there is some different way to connect swing application to oracle
Designing of textfield arrays in Netbeans IDE - Swing AWT
Designing of textfield arrays in Netbeans IDE  Respected sir, Sir I want to create an array of Jtextfield in Jframe Form in Swing GUI in NetBeans IDE.... How can i do this.........???? I have a code which
jdbc &swing - Java Beginners
jdbc &swing  I've used a progress bar in a database file upload window using swing.. But I can't set the uploading processing time with the progress bar.. please help me as early as possible.. How can I use progress bar against
Multiple session problem - Swing AWT
Multiple session problem  I am working in a Linux based java swing application. Problem: I have optimized JDialog and JPanel for my use.... This problem is quite critical as UI looks quite unpredictable due
Servlet problem - JDBC
but however. It gives problem sometimes while at others it works perfectly. I m using jdbc-odbc driver. Can anybody help me plzzzz!!!!   Hi Friend
java swing problem - Java Beginners
java swing problem  i doesn't know about the panel in swings here i had created one frame then created a panel and i added that to my frame but which is not adding any item and it not showing that item on the panel tell me how
Jfree chart problem - Swing AWT
Jfree chart problem  hello i have a problem related to jfree chart i have some data and i want to display data in two different chart stacked area chart and line chart both in a single frame. That is hybrid combination
Java Swings problem - Swing AWT
Java Swings problem  Sir, I am facing a problem in JSplitPane. I want the divider in the splitpane to be customized. I have a splitpane with Horizontal orientation and here, there lies the divider between left component and right
Frame refresh problem - Swing AWT
to correct this problem....its urgent!! thnks in adv..  Hi Friend
LOGIN PROBLEM - JDBC
LOGIN PROBLEM   sir iam harikrishna studying B.Tech Fourth year sir... and passowrd then my problem is how can we write the code for validating the userid... with JSP AND JDBC can u plz.........send me the code for checking username
JDBC ODBC related problem
JDBC ODBC related problem  i WANT HELP RELATED TO JDBC CONNECTIVITY... con; con = DriverManager.getConnection("jdbc:odbc:Digambar... THE ERROR PART...... THE QUESTION N PROBLEM IS I WANT TO SELECTE PERTICULAR PAPER FROM
java programming problem - JDBC
java programming problem  Hi, Request you to provide the source code in Java for the following programming problem : upload .csv file data into oracle database. please send the solution to [email protected]
dsn problem - JDBC
me how to create dsn (jdbc ) at run time . when we will give our project... to remember to create dsn (jdbc): 1.Create an ODBC DSN Using the Windows... the driver To load the JDBC driver by calling the forName() static method
java programming problem - JDBC
java programming problem  Hi, Request you to provide a solution ( analysis & design & unit test plan & code & test criteria ) to the following problem to the following mail id : Problem : upload excel file data into oracle
Sequence generator problem - JDBC
,but problem is that when i insert a values it will work and inserted the values.this one i am showing in a table ,but problem is a that it is also created a new
mysql problem - JDBC
= "jdbc:mysql://localhost:3306/test"; Connection con=null; try
mysql problem - JDBC
mysql problem   hai friends i have some problem with image storing in mysql. i.e while i am using image(blob) for insert the image it says out of bound of size error. please provide the logic for storing normal maxi size
Problem when resizing the form - Swing AWT
Problem when resizing the form  Hi, I am facing a problem when... part for JInternalFrame Form is (which is generated by the netbeans... The EditorPane(Old) overlaps the HeadPane(new). I think this problem is occuring whenever
New Problem in Form Resizing - Swing AWT
New Problem in Form Resizing  Hi, I am using a MDI application... for JInternalFrame Form is (which is generated by the netbeans in initcomponents...)); The problem is arising when the user resizes the form. The EditorPane(old
problem in inserting data in databases created in netbeans using jsp..
problem in inserting data in databases created in netbeans using jsp.. ... created table inside netbeans through sql editor.and tried to make a login page whose... = DriverManager.getConnection("jdbc:mysql://localhost:3306/roseindia", "root", "root
java swing jdbc - Java Beginners
java swing jdbc  hello, i want to populate the data(ms access) to the jtable component and want to perform some operations on it like add,edit,delete. Again i want to store the updated data to the database. can you help me out
problem in swing program for opening two windows with same login credentials
problem in swing program for opening two windows with same login credentials  I Face two problems while writing the code in swing program 1.i... representation problem is when i delete a node the tree is not automatically
NetBeans
NetBeans  why Netbeans IDE is not commonly used Today by most of the companies
SWT_AWT bridge ,jtextfield edit problem - Swing AWT
bridge in my code to embed swing components in to SWT Composite. I am using SWT_AWT bridge frame and adding JTextfield to it, My problem is that the JTextfield...); Thanks in advance.  Hi friend, Code to solve the problem
NetBeans
NetBeans  Hi, I am Kundan I have made a project on NetBeans. And now I want to know that how can i run my project without NetBeans IDE,on other PC. Please help me it's important
NetBeans
NetBeans  Hi, I am Kundan I have made a project on NetBeans. And now I want to know that how can i run my project without NetBeans IDE,on other PC. Please help me it's important
netbeans
netbeans  In netbeans, there are choices of books with their price. you check the book you wanted then click the purchase.the output should be the book with the price then you will get the total price of the book you purchase.how
Problem to get connection from DAO class to JDBC
Problem to get connection from DAO class to JDBC  package controller; import java.sql.Connection; import java.sql.DriverManager; public class... { String DRIVER="oracle.jdbc.driver.OracleDriver"; String URL="jdbc:oracle

Ads