PostgreSQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesPostgreSQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 27th, 2004, 01:45 AM
Manika Manika is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 27 Manika User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old July 27th, 2004, 10:46 AM
metaBarf metaBarf is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 373 metaBarf User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 49 m 6 sec
Reputation Power: 6
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

Reply With Quote
  #3  
Old July 28th, 2004, 03:45 AM
Manika Manika is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 27 Manika User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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:
Originally Posted by metaBarf
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

Reply With Quote
  #4  
Old July 28th, 2004, 07:21 AM
Manika Manika is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 27 Manika User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #5  
Old July 28th, 2004, 09:52 AM
metaBarf metaBarf is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 373 metaBarf User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 49 m 6 sec
Reputation Power: 6
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.

Reply With Quote
  #6  
Old July 28th, 2004, 10:44 AM
kurious's Avatar
kurious kurious is offline
Prom night: 1973
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Dec 2001
Posts: 1,152 kurious User rank is Corporal (100 - 500 Reputation Level)kurious User rank is Corporal (100 - 500 Reputation Level)kurious User rank is Corporal (100 - 500 Reputation Level)kurious User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Week 2 Days 7 h 36 m 22 sec
Reputation Power: 11
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 		+ "'"   +
	")"
;

Reply With Quote
  #7  
Old July 29th, 2004, 12:24 AM
Manika Manika is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 27 Manika User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesPostgreSQL Help > PostgreSQL +JSP


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT