Please find attached Doc2.doc. It is a pic of my program.
(this program successfully outputs the entire database. Yet I would like to learn the general steps to click the search button and perform a query.
further please find the method I have for a search @Action.
I am not clear on the procedure.
I have to write the query (below) in the java format. I think I have to change the query so it will conform to libraries???
Any way I am not sure of the right way to
1. make the query.
2. create a list
3.add the result set to a list
4.display the list in the textarea.
Could someone describe the steps to begin this?

mysql> SELECT artist,song,book_title,page_num FROM content WHERE artist LIKE "%b
lue oyster cult%";
+------------------+-----------------------+------------------------------------
+----------+
| artist           | song                  | book_title
| page_num |
+------------------+-----------------------+------------------------------------
+----------+
| Blue Oyster Cult | Don t Fear the Reaper | Guitar Tab White Pages Vol 1
|      210 |
| Blue Oyster Cult | Godzilla              | Guitar Tab White Pages Vol 1
|      271 |
| Blue Oyster cult | Burning for you       | Guitar Tab White Pages Vol 3
|      193 |
| Blue Oyster Cult | Burning for You       | The Greatest Rock Guitar Fake Book
|       48 |
| Blue Oyster Cult | Dont Fear the Reaper  | The Greatest Rock Guitar Fake Book
|       97 |
+------------------+-----------------------+------------------------------------
+----------+
5 rows in set (0.02 sec)

mysql>
@Action
    public Task search() {
       return new SearchTask(getApplication());
    }

    private class SearchTask extends Task {
        private String searchQuery;
        private List searchList;

       
        SearchTask(org.jdesktop.application.Application app) {
            super(app);
            
        searchList = org.jdesktop.observablecollections.ObservableCollections.observableList(query.getResultList());
        
        }
        //public <PropertyType> get<PropertyName>();

          
        @Override protected Void doInBackground() {
            try {
                setProgress(0, 0, 4);
                setMessage("Rolling back the current changes...");
                setProgress(1, 0, 4);
                entityManager.getTransaction().rollback();
                Thread.sleep(1000L); // remove for real app
                setProgress(2, 0, 4);

                setMessage("Starting a new transaction...");
                entityManager.getTransaction().begin();
                Thread.sleep(500L); // remove for real app
                setProgress(3, 0, 4);

                setMessage("Fetching new data...");
                java.util.Collection data = query.getResultList();
                Thread.sleep(1300L); // remove for real app
                setProgress(4, 0, 4);

                Thread.sleep(150L); // remove for real app
                searchList.clear();
                searchList.addAll(data);
            } catch(InterruptedException ignore) { }
            return null;
        }

Go through the JDBC tutorials, then go through the Swing tutorials, then, make sure you don't mix the two into the same class.

Connection con = DriverManager.getConnection(url, "Fernanda", "J8");

Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
                                     ResultSet.CONCUR_READ_ONLY);
ResultSet srs = stmt.executeQuery("SELECT COF_NAME, PRICE FROM COFFEES");

WHILE(rst.next())

ResultSet srs = stmt.executeQuery("select COF_Name from COFFEES " +
"where price = 7.99");
srs.next();

I went thru that material and it all look farmiliar.
The program I am trying to understand and work with uses this kind of code.
I am not sure where to begin maybe I "binding" or persistance.
If I could find a good example to see what is going on with this code.

entityManager = javax.persistence.Persistence.createEntityManagerFactory("splashbookdbPU").createEntityManager();
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(splashapp.SplashApp.class).getContext().getResourceMap(SplashView.class);
        query = entityManager.createQuery(resourceMap.getString("query.query")); // NOI18N
        list = org.jdesktop.observablecollections.ObservableCollections.observableList(query.getResultList());

public interface EntityManager

Interface used to interact with the persistence context.

An EntityManager instance is associated with a persistence context. A persistence context is a set of entity instances in which for any persistent entity identity there is a unique entity instance. Within the persistence context, the entity instances and their lifecycle are managed. This interface defines the methods that are used to interact with the persistence context. The EntityManager API is used to create and remove persistent entity instances, to find entities by their primary key, and to query over entities.

The set of entities that can be managed by a given EntityManager instance is defined by a persistence unit. A persistence unit defines the set of all classes that are related or grouped by the application, and which must be colocated in their mapping to a single database.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.