Sorry, it seems I sent a blank reply.. Anyway... I had the same problem with using JNDI with realm.. and finally I wrote a context.xml which works fine..
/meta-inf/context.xml: <Context docBase="PMS" path="/PMS" reloadable="true"> <Resource name="jdbc/pmsRead" auth="Container" type="javax.sql.DataSource" username="user" password="userpwd" driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/pms" maxActive="100" maxIdle="10" /> <!-- Authentication realm --> <Realm className="org.apache.catalina.realm.DataSourceRealm" localDataSource="true" dataSourceName="jdbc/pmsRead" debug="99" roleNameCol="role" userCredCol="password" userNameCol="username" userRoleTable="roles" userTable="users" /> </Context> The Resource jdbc/pmsRead works fine with the realm and within every class of my web application if I access it using the following code; try{ Context initCtx = new InitialContext(); Context envCtx = (Context) initCtx.lookup("java:comp/env"); DataSource ds = (DataSource) envCtx.lookup("jdbc/pmsRead"); Connection conn = ds.getConnection(); [query code here..] }catch(Exception e){ [some code here...] } Hope it can help someway.. Ale -----Messaggio originale----- Da: Stephen More [mailto:[EMAIL PROTECTED] Inviato: venerdì 19 maggio 2006 13.40 A: Tomcat Users List Oggetto: Re: Help with Tomcat & MySQL using JNDI On 5/17/06, Parsons Technical Services <[EMAIL PROTECTED]> wrote: > Now I will assume you have reviewed http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html > for a per context and Yes > http://tomcat.apache.org/tomcat-5.5-doc/config/globalresources.html for a > global approach. Yes. > Now for a few questions. > Is the jndi for one app or several? Right now, one app. > Well if for one app, you can set it up in the context of the app. I have been trying to do this. > Both cases you need to add the drivers to the common/lib (thus the reason a > simple war won't do). I have copied mysql-connector-java-3.1.12-bin.jar to apache-tomcat-5.5.17/common/lib > Class.forName("com.mysql.jdbc.Driver"); > > connection = > DriverManager.getConnection( > "jdbc:mysql://192.168.1.19:3306/golive", > "daname", > "depassword"); > I have this working fine. Now that we have verified this first layer ( JDBC Driver installed OK ), how can I test the next layer ? $CATALINA_HOME/webapps/DBTest/META-INF/context.xml What can I do to verify that my context.xml is set correctly ? -Thanks Steve More > ----- Original Message ----- > From: "Stephen More" <[EMAIL PROTECTED]> > To: <users@tomcat.apache.org> > Sent: Wednesday, May 17, 2006 5:34 PM > Subject: Help with Tomcat & MySQL using JNDI > > > Is there a war file available for download that will do nothing more than: > select 'HelloWorld from MySQL'; using JNDI ? > > > I have tried following many examples on the web and I keep ending up with: > Cannot create JDBC driver of class '' for connect URL 'null' > > At this point I am pulling out my hair and thinking their must be a > bug in tomcat 5.5.17 ! > > Can anyone provide me with a simple working war using MySQL ? > > > -Thanks > Steve More > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]