• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

Compilation Fails

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

In my Servlet project,im using the following query to fetch those employee names which are LIKE the variable "emp". But while i compile this i'm getting a "Incompatible type" compilation error.

If anyone knows the answer, plz help me out.....

String sql_getAll = "select * from DEPARTMENT WHERE EMPNAME LIKE '" + %emp% + "';";

I'm using this query along with Result Set.


Thnaks in Advance...
P.karthikeyan
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Karthikeyan,

why do you need a %emp% in your String statement ???

just use

String sql_getAll = "select * from DEPARTMENT WHERE EMPNAME LIKE '" +emp+ "';";

and i guess things should work fine.

cheers,

Kannan
 
karthikeyan piramanayagam
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank u very much, but, since i'm using the LIKE keyword, i should use the % otherwise it will not fetch all the relevant names. So i have use the %. So if u ahve any other ideas plz let me know

regards...
P.karthikeyan
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Then you put the % inside the String quotes:

String sql_getAll = "select * from DEPARTMENT WHERE EMPNAME LIKE '%" + emp + "%'";
Also, you do not need the semicolon inside the string, it will cause errors.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to the JDBC forum.

Dave
 
reply
    Bookmark Topic Watch Topic
  • New Topic