|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
PostgreSQL +JSP
HI Folks!
I am a PostgreSQL + JSP newbie. I am looking for resources that could provide me with some examples on postgresql with jsp. I am using tables instead of classes. In case the environments details are required, here they are:I am using: PostgreSQL7.2 Tomcat 4.1.30 Apache 1.3 JDBC Driver pg72jdbc2 JDK 1.4.2_04 Any help would be truly appreciated. Cheers, Manika |
|
#2
|
|||
|
|||
|
http://www.commandprompt.com/ppbook/index.lxp?lxpwrap=x20856%2ehtm
manika, there's nothing special about jsp's compared to regular java classes using the JDBC driver. JSP's are really servlets that are easier to write, and interpreted into servlet code -- you will have to load the driver with the driver manager, create a connection, create a statement, execute the statement just like a regular class. There are some special things you can do though, if you can set them up -- for instance, you can execute stored procedures from the java code. Here is an article from developerworks with a ton of info that will help you out: http://www-106.ibm.com/developerworks/java/library/j-datman.html here is another one from o'reilly: http://www.onjava.com/pub/a/onjava/2003/08/13/stored_procedures.html To set up a robust architecture with J2EE, you will have to look into making the datasource reference-able through JNDI. here's an article that talks about setting that up: http://www.castor.org/pooling.html#PostgreSQL-7.3,-JNDI-and-Tomcat |
|
#3
|
|||
|
|||
|
Hi,
Thanks a lot for all these links.I would go through them right away. By the way, I am a java newbie too...... ![]() Cheers. Quote:
|
|
#4
|
|||
|
|||
|
Hi,
I have a query.I was wondering if you could help me out with this. I run a jsp code and get the following error : 1.unclosed character literal An error occurred at line: 9 in the jsp file: /jsp/insert_cp.jsp Generated servlet error: [javac] Compiling 1 source file /usr/local/jakarta-tomcat-4.1.30/work/Standalone/localhost/examples/jsp/insert_cp_jsp.java:88: unclosed character literal String Query = "insert into user_info values ("'"+username+"','"+password+"','"+firstname+"','"+lastname+"','"+housenumber+"','"+streetname+"','"+area+"','"+city+"','"+postalcode+"','"+country+"','"+emailaddress+"','"+re_pass+"'")"; 2.unclosed string literal. An error occurred at line: 9 in the jsp file: /jsp/insert_cp.jsp Generated servlet error: /usr/local/jakarta-tomcat-4.1.30/work/Standalone/localhost/examples/jsp/insert_cp_jsp.java:88: unclosed string literal String Query = "insert into user_info values ("'"+username+"','"+password+"','"+firstname+"','"+lastname+"','"+housenumber+"','"+streetname+"','"+area+"','"+city+"','"+postalcode+"','"+country+"','"+emailaddress+"','"+re_pass+"'")"; ^ 2 errors Any help will be truly appreciated. Cheers, Manika |
|
#5
|
|||
|
|||
|
manika, I believe your problem is caused just by something wrong with the number of apostrophes you've got. I know postgres is picky as well as java with this issue -- I think you need to have a single apostrophe around each string, and then you want to have a double-quote on each of the servlet variables you are using. It seems like you have both problems since the servlet is complaining about the code it is trying to process.
|
|
#6
|
||||
|
||||
|
This should be in the Java forum. Try putting your queries on more than one line.
Code:
String Query =
"insert into user_info values (" +
" '" + username + "', " +
" '" + password + "', " +
" '" + firstname + "', " +
" '" + lastname + "', " +
" '" + housenumber + "', " +
" '" + streetname + "', " +
" '" + area + "', " +
" '" + city + "', " +
" '" + postalcode + "', " +
" '" + country + "', " +
" '" + emailaddress + "', " +
" '" + re_pass + "'" +
")"
;
|
|
#7
|
|||
|
|||
|
Thanks kurious & metaBarf,
You both were right. The error had to do something with the missing apostrophe. I put the entire string in mutiple lines and got it running. Thanks once again. Cheers, Manika |
![]() |
| Viewing: Dev Shed Forums > Databases > PostgreSQL Help > PostgreSQL +JSP |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|