Same query working in MySQL, and not in Java Client -
This query gets the correct value when running in the MySQL workbench
from person to person Select where the person_name = 'John Adam';
But when I run it from Java code, it gives an exception to that line in which the executeQuery () is called.
SQLState: 42S22 Error code: 1054 Message: Unknown column 'where segment' in 'John Adam'
My code is:
< Pre> string input name = JOptionPane.showInputDialog ("Enter person's name:"); String query = "Select person from person, where person_name =" + input name; Try {stmt = con.createStatement (); Results set rs = stmt.executeQuery (query); // Exception on this line while (rsnext ()) {rid = rs.getInt ("person_id"); } // .....
What could be the reason for this?
string query = "select from person" + "Where is the person from Person_name = '"+ inputname +"' '";
Comments
Post a Comment