java - Getting user input and then storing in resultSet list -


i have following code, gui image searcher part of main gui, goal point of view user input print out user input , add user input set of jtextfields , use input search database matching images, user doesn't need select 3 search criteria, one. question need guidance on how store user input in result set list, , use stored information query database.

so far i've tried grabbing user input, im unsure need next.

class displaysearch {     // database url                                    static final string database_url = "jdbc:mysql://localhost:3306/mysql";     static final string username = "root";     static final string password = "root";      // launch application     public static void search(string imagename, string datestamp, string imagetag) throws classnotfoundexception, instantiationexception, illegalaccessexception {         connection connection = null; // manages connection         statement statement = null; // query statement         resultset resultset = null; // manages results          // connect database books , query database         try {             // establish connection database             class.forname("com.mysql.jdbc.driver").newinstance();             connection = drivermanager.getconnection(database_url, username, password);              // create statement querying database             statement = connection.createstatement();              // query database                                                     resultset = statement.executequery(                     "select imagename, datestamp, imagetag images");              // process query results                system.out.println("search criteria");             while (resultset.next()) {                  // position cursor                  imagename = resultset.getstring(0);                  datestamp= resultset.getstring(1);                  imagetag = resultset.getstring(2);                  system.out.println("datas : " + imagename + " " + datestamp + " " + imagetag );              //while (resultset.next()) {                 if (imagename != "" || imagename != null) {                     string name = resultset.getstring(imagename);                     system.out.print("image name: " + name);                     resultset = statement.executequery("select imagename, datestamp, imagetag images imagename='"                             + imagename + "'");                 }                  if (datestamp != null) {                     string date = resultset.getstring(datestamp);                     system.out.print(", date: " + date);                     resultset = statement.executequery("select imagename, datestamp, imagetag images datestamp='"                             + datestamp + "'");                 }                  if (imagetag != "" || imagetag != null) {                     string tag = resultset.getstring(imagetag);                     system.out.print(", tag: " + tag);                     resultset = statement.executequery("select imagename, datestamp, imagetag images imagetag='"                             + imagetag + "'");                 }             } // end while         } // end try         catch (sqlexception sqlexception) {             sqlexception.printstacktrace();         } // end catch                                                              // ensure resultset, statement , connection closed         {             try {                 resultset.close();                 statement.close();                 connection.close();             } // end try                                                            catch (exception exception) {                 exception.printstacktrace();             } // end catch                                                      } // end                                                  } 

why want store data in resultset object? think not recommended way. can use variable store values , use them query data result set


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -