Results 1 to 4 of 4
  1. #1
    MS-POWER is offline Member
    Join Date
    Oct 2016
    Posts
    24
    Rep Power
    0

    Default Retrieve data from database and display it in the buttons

    Hi Dear


    I need a help please ...

    How to Retrieve data from database and display it in the buttons, and by clicking the button it will insert data in JtextField in main Frame

    as shown in the below photo.








    thanks

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: Retrieve data from database and display it in the buttons

    That is a lot of small steps there.
    Which bit(s) are you having issues with?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    MS-POWER is offline Member
    Join Date
    Oct 2016
    Posts
    24
    Rep Power
    0

    Default Re: Retrieve data from database and display it in the buttons

    Quote Originally Posted by Tolls View Post
    That is a lot of small steps there.
    Which bit(s) are you having issues with?
    thanks

    I don't know how to do it, I just need guidelines so I can start .


    best regards

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: Retrieve data from database and display it in the buttons

    Well, I would start with the code to retrieve the data you want from the database, but that's mostly because that's where I work.

    Write a class (we call these Data Access Objects, DAO for short) which queries the database using JDBC and SQL to get the data you need for your buttons. If it is a single String needed per button then you can simply have it return a List<String>. If, however, you have more data you want to return then I would write a second class called Employee that holds the data for a single Employee (name, employeeNumber, whatever else) and have your query method return a List<Employee>.

    You can test those by having a simple test harness class like this:
    Java Code:
    package test.things;
    
    import java.util.List;
    
    import your.app.package.dao.EmployeeDAO;
    import your.app.package.model.Employee;
    
    public class TestStuff {
        public static void main( String[] args) {
            EmployeeDAO dao = new EmployeeDAO();
            List<Employee> employees = dao.getEmployees();
            // loop over the list to print out the names.
        }
    }
    I wouldn't worry about the GUI code until I knew I was getting the correct data.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Using ListView to Retrieve Data from Database
    By boyfunky in forum Android
    Replies: 7
    Last Post: 07-09-2014, 07:47 PM
  2. Replies: 5
    Last Post: 05-23-2014, 10:07 AM
  3. how to retrieve data using <select> tag from database
    By shyamgsk in forum Java Servlet
    Replies: 6
    Last Post: 09-20-2013, 04:10 PM
  4. Replies: 3
    Last Post: 09-08-2012, 03:38 AM
  5. how to display data from oracle database?
    By deru4jesus in forum JavaServer Faces (JSF)
    Replies: 0
    Last Post: 04-16-2009, 08:46 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •