You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Andrew Falanga <af...@linora.com> on 2002/03/04 22:18:49 UTC

Setting up jdbc connections

Hello everyone,

    Setting up Tomcat is NO easy project.  I've been struggling for 
about a week and a half to get tomcat to read a special 
servlet/application/I really don't know what to call it. 
 (Unfortunately, that's my biggest problem, I'm very unfamiliar with 
things I'm playing around with right now.)

    Ok, in simplest terms possible here's the deal.  I'm trying to get a 
working model of something my company calls a portal.  Basically, it's 
nothing more than a product that will allow a person to use *.jsp 
rendered web pages to access/control/manipulate data contained withing 
Oracle databases.  This is the long term.  Right now, I need to get the 
application working to allow someone to log in.  The database which 
controls user access is NOT part of Oracle.  It is a PostgreSQL database.

    How, exactly, do I setup the JDBC stuff to interact with PostgreSQL? 
 I've been reading through the users guide, the paper on server.xml and 
the FAQ.  The information is comprehensive, I do think lacking in some 
parts, but none-the-less comprehensive.  (I do not mean to start flame 
wars or anything else.  However, for example, I downloaded and installed 
tomcat 3.3a via rpm for Red Hat Linux, the rpm was made by tomcat 
developers not red hat.  After installing, I'm reading through the users 
guide and there are several directories meantioned that DO NOT exist. 
 Such as, %TOMCAT_HOME/bin and many others.  This is what I mean by 
lacking.)


    How exactly am I going to go about setting up the database 
connectivity?  From what I've read, I've got to configure some kind of a 
JDBC Realm in the server.xml, but how exactly.  I did try, following the 
syntax example given in one of the user guide documents, but after 
restarting tomcat, tomcat was broken.  Absolutely, nothing was being 
served up.  I did make syntax substitutions to allow for my database vs. 
the database given in the example, and yes I'm absolutely open to the 
fact that my syntax was wrong.  Basically, what needs to be done?  I'm 
really nearing the end of my rope on this one.

Andy


--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>


Re: Setting up jdbc connections

Posted by Lev Assinovsky <le...@peterlink.ru>.
Here is how I install mysql JDBC.
1. In server.xml (no need realm):
          <Resource name="lev/DataSource" auth="Container"
                    type="javax.sql.DataSource"/>
          <ResourceParams name="lev/DataSource">
            <parameter><name>user</name><value>...</value></parameter> <!--
your login -->

<parameter><name>password</name><value>...</value></parameter><!-- your
passwd -->
            <parameter><name>driverClassName</name>
              <value>org.gjt.mm.mysql.Driver</value></parameter>
            <parameter><name>driverName</name>
              <value>jdbc:mysql://localhost:3306/WV</value></parameter>
          </ResourceParams>

2. In $CATALINA_HOME/webapps/examples/WEB-INF/web.xml:

    <resource-ref>
      <res-ref-name>lev/DataSource</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
      <res-sharing-scope>Shareable</res-sharing-scope>
    </resource-ref>

3. In yout JSP or Bean:
     Context ctx  = new InitialContext();
     Context envCtx = (Context)ctx.lookup("java:comp/env");
     DataSource _ds = (DataSource)envCtx.lookup("lev/DataSource");
     ....
     Connection con _ds.getConnection();
     ...
     Statement st = con.createStatement(...);
     ResultSet rs = st.executeQuery("select * from bla_bla");

JNDI will create instance of your DataSource (with automatic connection).
But you have to have tyrex*.jar in one of common dirs.
If not I advise you to switch to Tomcat 4.0.x.
Also you must put your (Postgres) JDBC jar into $CATALINA_HOME/lib
Good luck.

Andrew Falanga wrote:

> Hello everyone,
>
>     Setting up Tomcat is NO easy project.  I've been struggling for
> about a week and a half to get tomcat to read a special
> servlet/application/I really don't know what to call it.
>  (Unfortunately, that's my biggest problem, I'm very unfamiliar with
> things I'm playing around with right now.)
>
>     Ok, in simplest terms possible here's the deal.  I'm trying to get a
> working model of something my company calls a portal.  Basically, it's
> nothing more than a product that will allow a person to use *.jsp
> rendered web pages to access/control/manipulate data contained withing
> Oracle databases.  This is the long term.  Right now, I need to get the
> application working to allow someone to log in.  The database which
> controls user access is NOT part of Oracle.  It is a PostgreSQL database.
>
>     How, exactly, do I setup the JDBC stuff to interact with PostgreSQL?
>  I've been reading through the users guide, the paper on server.xml and
> the FAQ.  The information is comprehensive, I do think lacking in some
> parts, but none-the-less comprehensive.  (I do not mean to start flame
> wars or anything else.  However, for example, I downloaded and installed
> tomcat 3.3a via rpm for Red Hat Linux, the rpm was made by tomcat
> developers not red hat.  After installing, I'm reading through the users
> guide and there are several directories meantioned that DO NOT exist.
>  Such as, %TOMCAT_HOME/bin and many others.  This is what I mean by
> lacking.)
>
>     How exactly am I going to go about setting up the database
> connectivity?  From what I've read, I've got to configure some kind of a
> JDBC Realm in the server.xml, but how exactly.  I did try, following the
> syntax example given in one of the user guide documents, but after
> restarting tomcat, tomcat was broken.  Absolutely, nothing was being
> served up.  I did make syntax substitutions to allow for my database vs.
> the database given in the example, and yes I'm absolutely open to the
> fact that my syntax was wrong.  Basically, what needs to be done?  I'm
> really nearing the end of my rope on this one.
>
> Andy
>
> --
> To unsubscribe:   <ma...@jakarta.apache.org>
> For additional commands: <ma...@jakarta.apache.org>
> Troubles with the list: <ma...@jakarta.apache.org>

--
Lev Assinovsky                Peterlink Web
Programmer                    St. Petersburg, Russia
Tel/Fax: +7 812 3275343       197022 ul.Chapigina 7а
E-mail: lev@peterlink.ru




--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>


CONNECTION BUSY

Posted by Gurmeet <gu...@indicom.co.in>.
How do I resolve 

"[Microsoft][ODBC SQL Server Driver]Connection is busy with results for another hstmt"


problem. This is coming only if I am executing a no. of SQLs in quick succession.

Please Help.

Regards
Gurmeet


--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>


Re: Setting up jdbc connections

Posted by Emir Alikadic <ea...@sympatico.ca>.
On 03/04/2002 04:18 PM, Andrew Falanga wrote:

>Hello everyone,
>

Hi,

>
>    Setting up Tomcat is NO easy project.  I've been struggling for 
>about a week and a half to get tomcat to read a special 
>servlet/application/I really don't know what to call it. 
> (Unfortunately, that's my biggest problem, I'm very unfamiliar with 
>things I'm playing around with right now.)
>

Setting up Tomcat is a breeze, but not for somebody who doesn't know the 
difference between a servlet and an application.

>
>    Ok, in simplest terms possible here's the deal.  I'm trying to get a 
>working model of something my company calls a portal.  Basically, it's 
>nothing more than a product that will allow a person to use *.jsp 
>rendered web pages to access/control/manipulate data contained withing 
>Oracle databases.  This is the long term.  Right now, I need to get the 
>application working to allow someone to log in.  The database which 
>controls user access is NOT part of Oracle.  It is a PostgreSQL database.
>

Designing and implementing that "nothing more than a product" is what 
many of us have gone through 4 years of university and hundreds of books 
and white papers to learn to do.

>
>    How, exactly, do I setup the JDBC stuff to interact with PostgreSQL? 
> I've been reading through the users guide, the paper on server.xml and 
>the FAQ.  The information is comprehensive, I do think lacking in some 
>parts, but none-the-less comprehensive.  (I do not mean to start flame 
>wars or anything else.  However, for example, I downloaded and installed 
>tomcat 3.3a via rpm for Red Hat Linux, the rpm was made by tomcat 
>developers not red hat.  After installing, I'm reading through the users 
>guide and there are several directories meantioned that DO NOT exist. 
> Such as, %TOMCAT_HOME/bin and many others.  This is what I mean by 
>lacking.)
>

If you don't understand that $TOMCAT_HOME (or %TOMCAT_HOME%, if you're 
on WIndows) refers to the environment variable TOMCAT_HOME you were 
supposed to create as part of installation, I suggest you go back and 
first learn a few basics of the operating system you're working on (mail 
headers indicate Linux).

>
>    How exactly am I going to go about setting up the database 
>connectivity?  From what I've read, I've got to configure some kind of a 
>JDBC Realm in the server.xml, but how exactly.  I did try, following the 
>syntax example given in one of the user guide documents, but after 
>restarting tomcat, tomcat was broken.  Absolutely, nothing was being 
>served up.  I did make syntax substitutions to allow for my database vs. 
>the database given in the example, and yes I'm absolutely open to the 
>fact that my syntax was wrong.  Basically, what needs to be done?  I'm 
>really nearing the end of my rope on this one.
>

For basic database connectivity you don't need JDBC realm, all you need 
is a JDBC driver for the RDBMS you're working with (PostgreSQL or 
Oracle) and use the "regular" JDBC syntax in either JSPs or servlets. 
 You can also use JDBC taglib, but you still need the driver.  If this 
paragraph doesn't make sense, I suggest you stay away from Tomcat until 
you learn the basics of Java and J2EE programming.

>
>Andy
>

Emir.


--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>


Re: Setting up jdbc connections

Posted by Joel Rees <jo...@alpsgiken.gr.jp>.
Andrew Falanga wrote:

> However, for example, I downloaded and installed
> tomcat 3.3a via rpm for Red Hat Linux,
> ...
>  Such as, %TOMCAT_HOME/bin and many others.

This looks kinda weird to me.

Can you provide more specifics to our helpful friends on the list? OS?
Hardware? Did you ever get the examples to run? Where did you get the RPM?
(CD?Redhat?jakarta?) Did you let it unpack by the defaults? Etc.

Joel Rees




--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>