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: <mailto:[EMAIL PROTECTED]>
> For additional commands: <mailto:[EMAIL PROTECTED]>
> Troubles with the list: <mailto:[EMAIL PROTECTED]>
--
Lev Assinovsky Peterlink Web
Programmer St. Petersburg, Russia
Tel/Fax: +7 812 3275343 197022 ul.Chapigina 7�
E-mail: [EMAIL PROTECTED]
--
To unsubscribe: <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>