i am trying to design a servlet which will access user comments from a table in an access database. i was using oracle and cannot resolve a problem with it so i switched to the access file i used prior. i have a statement that says:
String query = "SELECT Comment, Username, ISBN FROM Reviews WHERE ISBN LIKE '" + isbn + "'";
this compiles normally and then when opened gives a message "Microsoft ODBC Driver. Too few parameters. Expected 1." and then quits the apache tomcat server completely. there is another servlet i am using to access the same database in the previous page which has a similar statement:
String query = "SELECT Title, Author, ISBN, Cost, QuantityOnHand FROM Products ";
if ( title != null & ! title.equals ("" )
query = query + "WHERE Title LIKE '" + title + "' ";
if (author != null & ! author.equals ("" )
if (query.indexOf ("WHERE" == -1 )
query = query + "WHERE Author LIKE '" + author + "' ";
else
query = query + "OR Author LIKE '" + author + "' ";
if (isbn != null & ! isbn.equals ("" )
if (query.indexOf ("WHERE" == -1 )
query = query + "WHERE ISBN LIKE '" + isbn + "' ";
else
query = query + "OR ISBN LIKE '" + isbn + "' ";
I am a bit stumpped and i did not know if this should be posted on java, access or tomcat. so i will try here first. any suggestions for me?
String query = "SELECT Comment, Username, ISBN FROM Reviews WHERE ISBN LIKE '" + isbn + "'";
this compiles normally and then when opened gives a message "Microsoft ODBC Driver. Too few parameters. Expected 1." and then quits the apache tomcat server completely. there is another servlet i am using to access the same database in the previous page which has a similar statement:
String query = "SELECT Title, Author, ISBN, Cost, QuantityOnHand FROM Products ";
if ( title != null & ! title.equals ("" )
query = query + "WHERE Title LIKE '" + title + "' ";
if (author != null & ! author.equals ("" )
if (query.indexOf ("WHERE" == -1 )
query = query + "WHERE Author LIKE '" + author + "' ";
else
query = query + "OR Author LIKE '" + author + "' ";
if (isbn != null & ! isbn.equals ("" )
if (query.indexOf ("WHERE" == -1 )
query = query + "WHERE ISBN LIKE '" + isbn + "' ";
else
query = query + "OR ISBN LIKE '" + isbn + "' ";
I am a bit stumpped and i did not know if this should be posted on java, access or tomcat. so i will try here first. any suggestions for me?