×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

PostgreSQL Inc.: PostgreSQL FAQ

Java with Postgresql

How to configure Java with Postgresql by newbiepg
Posted: 19 Nov 03

Configuring Java/JSP with Postgresql in Redhat Linux


The first thing would be to install JDK for this. Go to this
URL  http://java.sun.com/j2se/1.4.2/download.html

This will ask you to agree to their terms and conditions

Choose the Linux self-extracting file in the second table on this page.

The download will be a binary file, log in as root and execute

./j2sdk-1_4_2_02-linux-i586-rpm.bin
and then
rpm -ivf j2sdk-1_4_2_02-linux-i586-rpm

This should install java in the folder /usr/java

Occasionally the binary file may not run, then add execute permissions

chmod 0777 j2sdk-1_4_2_02-linux-i586-rpm.bin
or
chmod +x  j2sdk-1_4_2_02-linux-i586-rpm.bin

and then run the two commands.

Then we need to configure java in the classpath.
I normally do this in the /etc/profile file.
This ensures that all users can access java.
Otherwise add these lines to the .bash_profile file
in your home directory.


PATH=/usr/java/j2sdk1.4.0/bin:$PATH
export PATH
export JAVA_HOME=/usr/java/j2sdk1.4.0
export CLASSPATH=/usr/java/j2sdk1.4.0/lib/tools.jar:/usr/java/j2sdk1.4.0/jre/lib/rt.jar


remember to run this file you have edited, otherwise log off and log on again or restart
the computer.

now type javac in the konsole or xterminal
this should throw a message explaining the syntax. If there is a
message saying that no command found, then there is an error in the configuration or you
have not restarted the computer.

Now we need a JSP server, tomcat is a free server.
Go to http://www.apache.org

and download the zipped file. They are the same for windows and linux.
Unzip the file and put it in a folder. I had put it in /usr/tomcat4.

Now go to the bin folder and type ./startup.sh
You should get a few lines of code mentioning java home,catalina home and a
couple more lines.

Now open a browser and type http://localhost:8080
You should see a welcome page with links.

Ensure that you have a web server on at that time(usually apache)

If you are root type

service httpd status

you should get a message mentioning PIDs and saying that the service is on

If not type service httpd start

Note that the service command works only if you are root , logged in as root
in the main terminal.

Service does not work if you have types su or have logged into the server
as root from another terminal.

Otherwise go to /etc/rc.d/init.d/
and then type httpd -k start(I am a little unsure about this part).



Now for the postgresql part.


Redhat 9.0 ships 3 postgresql rpms by default for versions 7.1, 7.2 and 7.3

type this command rpm -ql postgresql-jdbc*
This will display the 3 rpms (these are already installed, do not reinstall)

Choose the version according  to your postgresql database.

Now we need to copy these files into Tomcat's lib folder

 /usr/tomcat4/lib  or wherever tomcat has been unzipped.

That should be it.

Remember this will only give access to JSP pages to Postgresql.
If you want a .java file to have access to Postgresql they must be put
inside the JSP classes folder, normally the /WEB-INF/classes folder
inside Webapps or any other virtual directory.


Back to PostgreSQL Inc.: PostgreSQL FAQ Index
Back to PostgreSQL Inc.: PostgreSQL Forum


My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close