sql - java search-getting an integer value from a string preparedstatement -


i have java code, , want able search year (which int) textfield , show table. how implement in preparestatement? need parse?

try     {         connection = dbconnect.getconnection();           //int filmyear = integer.parseint(txtsearch.gettext());          statement = connection.preparestatement("select filmtitle, filmyear, filmgenre, companyname production, film, company  (lower(filmtitle) lower (?) or "         + "lower (filmgenre) lower (?) or filmyear = ?)and production.companyid = company.companyid , production.filmid = film.filmid");          statement.setstring(1, "%" +txtsearch.gettext()+"%");         statement.setstring(2, "%" +txtsearch.gettext()+"%");     //  statement.setint(3, +txtsearch.gettext());           resultset = statement.executequery();           table.setmodel(dbutils.resultsettotablemodel(resultset));      }catch(sqlexception e)     {         e.printstacktrace();     } 

as can see tried create statement.setint(3, +txtsearch.gettext());, suspect wrong.

filmtitle, filmgenre, , filmyear in same table.

any appreciated thanks

i think tried this. should working fine.

int filmyear = integer.parseint(txtsearch.gettext()); 

then

statement.setint(3, filmyear); 

Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

unity3d - Fatal error- Monodevelop-Unity failed to start -