Jump to content
xisto Community
Sign in to follow this  
tinoymalayil

To Get Data In Jtable From Database

Recommended Posts

Search Jtable and Database in google and you should come up with plenty of links and examples. Try them out and let us know how it goes.Good luck.

Share this post


Link to post
Share on other sites

Some pointers for you, JDBC + JTable Google results

 

 

* Hacking Swing: A JDBC Table Model

* Mastering the JTable

* Making SQL Queries with JDBC and Displaying Results with Swing

 

 

As suggested earlier if you're working with small set of data then you can use java.lang.Vector or you can TableModel and then you can show it on JTable. Hope this will help.

Share this post


Link to post
Share on other sites
Query about jdbc connectivityTo Get Data In Jtable From Database

Hi, I am really in a need of jdbc connectivity in net beans. Actually I hav created the login form module using Jframe and created , connected the database by Mysql, now I need by using which methodology I can retrieve data into my modle from database.. Pl pl reply soon if anybody know it!

-reply by Vandhena.K

Share this post


Link to post
Share on other sites
Query about jdbc connectivityTo Get Data In Jtable From Database

Not sure what your actual question is, or if you are lost and just want someone to give you complete code, probably that - here is an example from the web.  If you want to be effective with JDBC and Swing, there is no substitute for learning it though.

http://forums.xisto.com/no_longer_exists/;

-reply by Barry

 

Share this post


Link to post
Share on other sites

I used netbeans IDE to designed the form and the jtable. I used drag and drop in netbeans

private void getConnection(){//your connection code here}Connection con = getConnection();            try {                ResultSet rows;                Statement s = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);                String select = "Select * from project";                rows = s.executeQuery(select);                int i = 0;                while (rows.next()){                    String projName = rows.getString("projectName");                    String status = rows.getString("status");                    String date = rows.getString("date");                    String timeAllocated = rows.getString("timeAllocated");                    String timeSpent = rows.getString("timeSpent");                    String billing = rows.getString("billing");                                        //calling data into jtable for display                    projectTable.setValueAt(projName, i, 0);                    projectTable.setValueAt(status, i, 1);                    projectTable.setValueAt(date, i, 2);                    projectTable.setValueAt(timeAllocated, i, 3);                    projectTable.setValueAt(timeSpent, i, 4);                    projectTable.setValueAt(billing, i, 5);                    i++;                }            } catch (SQLException e) {                System.out.println(e.getMessage());            }    }

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.