Saturday, 15 June 2013

java - join SQL command not properly ended -



java - join SQL command not properly ended -

i have problem bring together statement

string q1="select e.employee_id,e.manager_id,e.first_name,e.last_name,e.salary,e.commission_pct,d.manager_id,d.employee_id employees e ,employees d e.manager_id=d.employee_id , e.employee_id="+jcombobox1.getselecteditem(); try{ oracledatasource ods=new oracledatasource(); ods.seturl("jdbc:oracle:thin:hr/hr@localhost:1521/xe"); connection con=ods.getconnection(); statement s=con.createstatement(); s.execute(q1); resultset rs=s.getresultset(); string x=(string)jcombobox1.getselecteditem(); while(rs.next()){ if (x.equals(rs.getstring("e.employee_id"))){ jtextfield1.settext(rs.getstring("e.first_name")); jtextfield2.settext(rs.getstring("e.last_name")); jtextfield3.settext(rs.getstring("e.salary")); jtextfield4.settext(rs.getstring("e.commission_pct")); jtextfield5.settext(rs.getstring("d.first_name")); } } con.close(); }catch(exception e){e.printstacktrace();}

how solve problem ?! ....................................................................................................................................................................................................................................

you should using prepared statement avoid sql injection problem. anyways issue is:

select e.employee_id,e.manager_id,e.first_name,e.last_name,e.salary,e.commission_pct,d.manager_id,d.employee_id employees e ,employees d e.manager_id=d.employee_id , e.employee_id="+jcombobox1.getselecteditem();

i see utilize rs.getstring employee_id, missing quotes e.employee_id field in clause.

java javascript sql command spring-jdbc

No comments:

Post a Comment