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;
}