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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Web server code not working properly

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
I'm having some trouble getting this code to work properly. /Although it compiles fully in cmd, for some reason I generate a 500 Internal Server Error Message when trying to retrieve either all items, or any item by ID. It also doesn't help that nothing happens when I try to retrieve something by "NumOfServings". Can anyone help point out what is exactly wrong with my current code???

This is the code that I am talking about that has compiled, but is not working properly...


This is the index.html file my jsp code is aiming to respond to...


If anyone can help identify what is causing my errors and non - functionality issues, it would be greatly appreciated. As I have debugged it myself and can't completely fix what's wrong here.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Please include the full text of the error message and stack trace (please UseCodeTags to preserve formatting), and please edit your code to have proper indentation. Your code is just too hard to read as an unindented block of code.
 
Shakur Burton
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
My java code for responding to html.index with...





My index.html file...


I'm sorry to forget these as well - the error stack for both:

1) My Retrieve All Method...
HTTP Status 500 - org.glassfish.jersey.server.ContainerException: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Enter in a Recipe ID from Recipe database, WHERE ID = 1' at line 1

type Exception report

message org.glassfish.jersey.server.ContainerException: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Enter in a Recipe ID from Recipe database, WHERE ID = 1' at line 1

description The server encountered an internal error that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: org.glassfish.jersey.server.ContainerException: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Enter in a Recipe ID from Recipe database, WHERE ID = 1' at line 1

root cause

org.glassfish.jersey.server.ContainerException: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Enter in a Recipe ID from Recipe database, WHERE ID = 1' at line 1

root cause

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Enter in a Recipe ID from Recipe database, WHERE ID = 1' at line 1


2) My Retrieve by ID method:
HTTP Status 500 - org.glassfish.jersey.server.ContainerException: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'the following values for Recipes: ID or NAME.' at line 1

type Exception report

message org.glassfish.jersey.server.ContainerException: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'the following values for Recipes: ID or NAME.' at line 1

description The server encountered an internal error that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: org.glassfish.jersey.server.ContainerException: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'the following values for Recipes: ID or NAME.' at line 1

root cause

org.glassfish.jersey.server.ContainerException: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'the following values for Recipes: ID or NAME.' at line 1

root cause

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'the following values for Recipes: ID or NAME.' at line 1
[/code]
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
It's pretty clear from the error messages that the problem is not with servlet technology but with your SQL syntax. I have moved this to the JDBC forum accordingly.
 
Shakur Burton
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Understood - I still need help cracking this error, unfortunately...
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Okay. So, somewhere in that code dump is the SQL statement which causes the exception. It would help if you could just post that instead of hoping people will trawl through what you posted.
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Never mind, I found it:



But that isn't even close to valid SQL. Did you accidentally copy and paste it from somewhere else, or did you really mean it to be an SQL statement?
 
Shakur Burton
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator

Paul Clapham wrote:Never mind, I found it:



But that isn't even close to valid SQL. Did you accidentally copy and paste it from somewhere else, or did you really mean it to be an SQL statement?



I admit that that was a full - on accident. I'm trying to get the code for Retrieving by ID in index.html to match my "Retrieve by ID" java code so it can work properly, for an example of my problems there.
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Sorry, but I'm totally lost. None of the strings you're trying to use in your Java code as SQL are anything like SQL. So trying to fiddle with the HTML to match that is not going to get you anywhere. If that's actually what you meant to say.

 
Shakur Burton
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
I'd like to close this thread then and start a new topic, in order to better deal with my situation, which I have. 2 or 3 of them, to be exact.
 
Please enjoy this holographic presentation of our apocalyptic dilemma right after this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
    Bookmark Topic Watch Topic
  • New Topic