Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jsp postgress connection

 
ankur mawandia
Greenhorn
Posts: 12
Eclipse IDE Java Postgres Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am trying to connect a jsp page to the postgres db

i have written a html form and i am trying to post the data to the database

i am reciving an error

the jsp page is





the error says
org.apache.jasper.JasperException: javax.servlet.ServletException: org.postgresql.util.PSQLException: ERROR: syntax error at or near "["
Position: 18

ng


thnx in advance
also i am still new so please point out the errors i am making

thnx




 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65337
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why is this code in a JSP rather than properly in a servlet?
 
ankur mawandia
Greenhorn
Posts: 12
Eclipse IDE Java Postgres Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i just want to check wether my postgres driver is properly installed or not.....and wether i can conncet to the database or not

 
Sunny Bhandari
Ranch Hand
Posts: 448
Eclipse IDE Firefox Browser Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not familiar with postgress but will advise to debug the code to check that the source of error is the INSERT statement.

You can also write a java class for that...
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65337
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do it in a Java class like a servlet. Doing this in a JSP is a poor practice and problematic.

Compiling a Java class is likely to give you better error messages as well.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ankur,
Welcome to CodeRanch!

I agree that it would be better to move this code out of the JSP. As for your error, it looks like you are connecting to the database and getting an error running the insert. There aren't braces around the column names in an insert. You can try running the SQL statement at the postgres command line to make sure it works.
 
ankur mawandia
Greenhorn
Posts: 12
Eclipse IDE Java Postgres Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you so much bear and jeanne..for your valueble sujjestion

the problems was in the query as you said
can you tell me how to set this properly in a servelet

 
Vijitha Kumara
Bartender
Pie
Posts: 3930
21
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
...can you tell me how to set this properly in a servelet

Modern JSPs should not contain any Java code (if possible even the old code should not). Move them to controller/model classes appropriately.

If you are new to web development you may want to look at the MVC pattern.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic