| Author |
jsp postgress connection
|
ankur mawandia
Greenhorn
Joined: Jan 10, 2011
Posts: 12
|
|
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
|
may the force be with you
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56230
|
|
|
Why is this code in a JSP rather than properly in a servlet?
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
ankur mawandia
Greenhorn
Joined: Jan 10, 2011
Posts: 12
|
|
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
Joined: Dec 06, 2010
Posts: 446
|
|
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
Joined: Jan 10, 2002
Posts: 56230
|
|
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
internet detective
Marshal
Joined: May 26, 2003
Posts: 26216
|
|
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.
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
ankur mawandia
Greenhorn
Joined: Jan 10, 2011
Posts: 12
|
|
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
Joined: Mar 24, 2008
Posts: 3670
|
|
...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.
|
SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
|
 |
 |
|
|
subject: jsp postgress connection
|
|
|