Re: DBCP Please Help Get Working Properly

2005-04-11 Thread David Smith
Ok, define 'no results'. In reality, the naming import isn't the only 
thing that changed. Your web.xml file *looks* like 2.3 spec from what I 
can see and you are using JSP 2.x spec syntax in your jsp. If you want 
the JSP 2.x spec features, you need to declare your web.xml file for 
servlet 2.4 spec. This should be up at the top of your web.xml (pasted 
from the specification for servlet 2.4):

?xml version=1.0 encoding=ISO-8859-1?
web-app xmlns=http://java.sun.com/xml/ns/j2ee;
xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;
xsi:schemaLocation=http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd;
version=2.4
Then just put all your servlet-mappings, etc., ... after that. The 
taglib declarations need to be inside a jsp-config element for the 2.4 
spec web.xml file too. That's how I'm guessing you have a 2.3 spec 
web.xml file. The full spec can be found at 
http://www.jcp.org/en/jsr/detail?id=154

--David
Scott Purcell wrote:
Hello,
I am trying to use the DBCP features of Tomcat 5.5.7. I created a webapp named 
testDB and put it under $CATALINA_HOME/webapps/testDB. Then I created a 
testDB.xml file under $CATALINA_HOME/conf/Catalina/localhost/testDB.xml.
// here it is
Context path=/testDB docBase=testDB
   debug=5 reloadable=true crossContext=true
 Resource name=jdbc/testDB auth=Container type=javax.sql.DataSource
  maxActive=100 maxIdle=30 maxWait=1
  username=javauser password=javadude 
driverClassName=com.mysql.jdbc.Driver
  url=jdbc:mysql://localhost:3306/fritest?autoReconnect=true/
/Context
I have been following the notes from: 
http://localhost/tomcat-docs/jndi-datasource-examples-howto.html

I made sure I completed the rest of the tasks.
WEB-INF has the two tag locations, and the resource ref.
eg:
   taglib
   taglib-uri/WEB-INF/sql.tld/taglib-uri
   taglib-location/WEB-INF/sql.tld/taglib-location
   /taglib
   taglib
   taglib-uri/WEB-INF/c.tld/taglib-uri
   taglib-location/WEB-INF/c.tld/taglib-location
   /taglib
 resource-ref
 descriptionDB Connection/description
 res-ref-namejdbc/testDB/res-ref-name
 res-typejavax.sql.DataSource/res-type
 res-authContainer/res-auth
 /resource-ref
I finally hit my jsp page which is this:
%@ taglib uri=http://java.sun.com/jsp/jstl/sql; prefix=sql %
%@ taglib uri=http://java.sun.com/jsp/jstl/core; prefix=c %
sql:query var=rs dataSource=jdbc/testDB
select id, foo, bar from testdata
/sql:query
html
 head
   titleDB Test/title
 /head
 body
 h2Results/h2
 
c:forEach var=row items=${rs.rows}
   Foo ${row.foo}br/
   Bar ${row.bar}br/
/c:forEach

 /body
/html
And I get no results:
Now I am pretty sure I have all configured. Because if I use a fallback (Tomcat 
4.1) code piece I had, I get results using the same settings:
package foo;
import javax.naming.*;
import javax.sql.*;
import java.sql.*;
public class DBTest {
 String foo = Not Connected;
 int bar = -1;
   
 public void init() {
   try{
 Context ctx = new InitialContext();
 if(ctx == null ) 
 throw new Exception(Boom - No Context);

 DataSource ds = 
   (DataSource)ctx.lookup(
  java:comp/env/jdbc/testDB);

 if (ds != null) {
   Connection conn = ds.getConnection();
 
   if(conn != null)  {
   foo = Got Connection +conn.toString();
   Statement stmt = conn.createStatement();
   ResultSet rst = 
   stmt.executeQuery(
 select id, foo, bar from testdata);
   while(rst.next()) {
  System.out.println(next );
  foo=rst.getString(2);
  bar=rst.getInt(3);
   }
   conn.close();
   }
 }
   }catch(Exception e) {
 e.printStackTrace();
   }
}

public String getFoo() { return foo; }
public int getBar() { return bar;}
}
And using the above class works all day.
The only difference I see is that the class using a naming import and the jsp 
does not. Can anyone help.
Thanks,
Scott




-Original Message-
From: David Smith [mailto:[EMAIL PROTECTED]
Sent: Friday, April 08, 2005 1:14 PM
To: Tomcat Users List
Subject: Re: Add Context Path, Tomcat 5.5.7
Hi.
Take a look at this for where to put Context elements:
http://jakarta.apache.org/tomcat/tomcat-5.5-doc/config/context.html
This is new with Tomcat 5.0 and is continued in Tomcat 5.5
--David
Scott Purcell wrote:
 

Hello,
I am following the information here to add DBCP to my application.
http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-datasource-examples-howto.html
I am reading to add the Context path=/DBTest ... from the above docs. The 
instructions say to .
Configure the JNDI DataSource in Tomcat by adding a declaration for your 
resource to $CATALINA_HOME/conf/server.xml.
Add this in between the /Context tag of the examples context and the /Host 
tag closing the localhost definition.

So cool, I opened up the server.xml, but do not see any existing context or 
host tags in it. Here is my 

RE: DBCP Please Help Get Working Properly

2005-04-11 Thread Scott Purcell
Thank David for the below information.

This makes some sense, and I will try and make the changes. But this of course 
leads to a follow-up question. Why isn't there any decent documentation to get 
the DBCP running in Tomcat. I am talking about a simple example, that explains 
container versions, jsp versions, possibly better ways to use then putting the 
connection into a JSP page. Connecting in a JSP page is just plain dirty, I 
would like to connect in some class where I can call connections from. Does 
this make sense?

As I mentioned, I followed the example that comes with the documentation for my 
5.5 Tomcat that displays when you go to localhost.

So, is there any good documentation that shows how to do this, step by step?


Thanks,
Scott






-Original Message-
From: David Smith [mailto:[EMAIL PROTECTED]
Sent: Monday, April 11, 2005 8:18 AM
To: Tomcat Users List
Subject: Re: DBCP Please Help Get Working Properly


Ok, define 'no results'. In reality, the naming import isn't the only 
thing that changed. Your web.xml file *looks* like 2.3 spec from what I 
can see and you are using JSP 2.x spec syntax in your jsp. If you want 
the JSP 2.x spec features, you need to declare your web.xml file for 
servlet 2.4 spec. This should be up at the top of your web.xml (pasted 
from the specification for servlet 2.4):

?xml version=1.0 encoding=ISO-8859-1?

web-app xmlns=http://java.sun.com/xml/ns/j2ee;
xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;
xsi:schemaLocation=http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd;
version=2.4

Then just put all your servlet-mappings, etc., ... after that. The 
taglib declarations need to be inside a jsp-config element for the 2.4 
spec web.xml file too. That's how I'm guessing you have a 2.3 spec 
web.xml file. The full spec can be found at 
http://www.jcp.org/en/jsr/detail?id=154

--David

Scott Purcell wrote:

Hello,

I am trying to use the DBCP features of Tomcat 5.5.7. I created a webapp named 
testDB and put it under $CATALINA_HOME/webapps/testDB. Then I created a 
testDB.xml file under $CATALINA_HOME/conf/Catalina/localhost/testDB.xml.

// here it is
Context path=/testDB docBase=testDB
debug=5 reloadable=true crossContext=true

  Resource name=jdbc/testDB auth=Container type=javax.sql.DataSource
   maxActive=100 maxIdle=30 maxWait=1
   username=javauser password=javadude 
 driverClassName=com.mysql.jdbc.Driver
   url=jdbc:mysql://localhost:3306/fritest?autoReconnect=true/
/Context

I have been following the notes from: 
http://localhost/tomcat-docs/jndi-datasource-examples-howto.html

I made sure I completed the rest of the tasks.
WEB-INF has the two tag locations, and the resource ref.
eg:

taglib
taglib-uri/WEB-INF/sql.tld/taglib-uri
taglib-location/WEB-INF/sql.tld/taglib-location
/taglib


taglib
taglib-uri/WEB-INF/c.tld/taglib-uri
taglib-location/WEB-INF/c.tld/taglib-location
/taglib

  resource-ref
  descriptionDB Connection/description
  res-ref-namejdbc/testDB/res-ref-name
  res-typejavax.sql.DataSource/res-type
  res-authContainer/res-auth
  /resource-ref

I finally hit my jsp page which is this:
%@ taglib uri=http://java.sun.com/jsp/jstl/sql; prefix=sql %
%@ taglib uri=http://java.sun.com/jsp/jstl/core; prefix=c %

sql:query var=rs dataSource=jdbc/testDB
select id, foo, bar from testdata
/sql:query

html
  head
titleDB Test/title
  /head
  body

  h2Results/h2
  
c:forEach var=row items=${rs.rows}
Foo ${row.foo}br/
Bar ${row.bar}br/
/c:forEach


  /body
/html

And I get no results:

Now I am pretty sure I have all configured. Because if I use a fallback 
(Tomcat 4.1) code piece I had, I get results using the same settings:

package foo;

import javax.naming.*;
import javax.sql.*;
import java.sql.*;

public class DBTest {

  String foo = Not Connected;
  int bar = -1;

  public void init() {
try{
  Context ctx = new InitialContext();
  if(ctx == null ) 
  throw new Exception(Boom - No Context);

  DataSource ds = 
(DataSource)ctx.lookup(
   java:comp/env/jdbc/testDB);

  if (ds != null) {
Connection conn = ds.getConnection();
  
if(conn != null)  {
foo = Got Connection +conn.toString();
Statement stmt = conn.createStatement();
ResultSet rst = 
stmt.executeQuery(
  select id, foo, bar from testdata);
while(rst.next()) {
   System.out.println(next );
   foo=rst.getString(2);
   bar=rst.getInt(3);
}
conn.close();
}
  }
}catch(Exception e) {
  e.printStackTrace();
}
 }

 public String getFoo() { return foo; }
 public int getBar() { return bar;}
}

And using the above class works all day.

The only difference I see is that the class using a naming import

Re: DBCP Please Help Get Working Properly

2005-04-11 Thread David Smith
Well yes it does make a lot of sense, but is more a question answered by 
design patterns.  It's a little beyond the scope of Tomcat docs to 
address issues like separation of roles.  Both Struts and Spring 
projects address issues like this with the Model-View-Controller (MVC) 
pattern and there are innumerable books on the subject as well.  
Specific to data access methods, Hibernate also addresses this issue.

As far as step by step docs, you are best off picking a framework, 
getting a good book on it and go from there.

Hope this helps.
--David
Scott Purcell wrote:
Thank David for the below information.
This makes some sense, and I will try and make the changes. But this of course 
leads to a follow-up question. Why isn't there any decent documentation to get 
the DBCP running in Tomcat. I am talking about a simple example, that explains 
container versions, jsp versions, possibly better ways to use then putting the 
connection into a JSP page. Connecting in a JSP page is just plain dirty, I 
would like to connect in some class where I can call connections from. Does 
this make sense?
As I mentioned, I followed the example that comes with the documentation for my 
5.5 Tomcat that displays when you go to localhost.
So, is there any good documentation that shows how to do this, step by step?
Thanks,
Scott


-Original Message-
From: David Smith [mailto:[EMAIL PROTECTED]
Sent: Monday, April 11, 2005 8:18 AM
To: Tomcat Users List
Subject: Re: DBCP Please Help Get Working Properly
Ok, define 'no results'. In reality, the naming import isn't the only 
thing that changed. Your web.xml file *looks* like 2.3 spec from what I 
can see and you are using JSP 2.x spec syntax in your jsp. If you want 
the JSP 2.x spec features, you need to declare your web.xml file for 
servlet 2.4 spec. This should be up at the top of your web.xml (pasted 
from the specification for servlet 2.4):

?xml version=1.0 encoding=ISO-8859-1?
web-app xmlns=http://java.sun.com/xml/ns/j2ee;
xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;
xsi:schemaLocation=http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd;
version=2.4
Then just put all your servlet-mappings, etc., ... after that. The 
taglib declarations need to be inside a jsp-config element for the 2.4 
spec web.xml file too. That's how I'm guessing you have a 2.3 spec 
web.xml file. The full spec can be found at 
http://www.jcp.org/en/jsr/detail?id=154

--David
Scott Purcell wrote:
 

Hello,
I am trying to use the DBCP features of Tomcat 5.5.7. I created a webapp named 
testDB and put it under $CATALINA_HOME/webapps/testDB. Then I created a 
testDB.xml file under $CATALINA_HOME/conf/Catalina/localhost/testDB.xml.
// here it is
Context path=/testDB docBase=testDB
  debug=5 reloadable=true crossContext=true
Resource name=jdbc/testDB auth=Container type=javax.sql.DataSource
 maxActive=100 maxIdle=30 maxWait=1
 username=javauser password=javadude 
driverClassName=com.mysql.jdbc.Driver
 url=jdbc:mysql://localhost:3306/fritest?autoReconnect=true/
/Context
I have been following the notes from: 
http://localhost/tomcat-docs/jndi-datasource-examples-howto.html

I made sure I completed the rest of the tasks.
WEB-INF has the two tag locations, and the resource ref.
eg:
  taglib
  taglib-uri/WEB-INF/sql.tld/taglib-uri
  taglib-location/WEB-INF/sql.tld/taglib-location
  /taglib
  taglib
  taglib-uri/WEB-INF/c.tld/taglib-uri
  taglib-location/WEB-INF/c.tld/taglib-location
  /taglib
resource-ref
descriptionDB Connection/description
res-ref-namejdbc/testDB/res-ref-name
res-typejavax.sql.DataSource/res-type
res-authContainer/res-auth
/resource-ref
I finally hit my jsp page which is this:
%@ taglib uri=http://java.sun.com/jsp/jstl/sql; prefix=sql %
%@ taglib uri=http://java.sun.com/jsp/jstl/core; prefix=c %
sql:query var=rs dataSource=jdbc/testDB
select id, foo, bar from testdata
/sql:query
html
head
  titleDB Test/title
/head
body
h2Results/h2
c:forEach var=row items=${rs.rows}
  Foo ${row.foo}br/
  Bar ${row.bar}br/
/c:forEach
/body
/html
And I get no results:
Now I am pretty sure I have all configured. Because if I use a fallback (Tomcat 
4.1) code piece I had, I get results using the same settings:
package foo;
import javax.naming.*;
import javax.sql.*;
import java.sql.*;
public class DBTest {
String foo = Not Connected;
int bar = -1;
  
public void init() {
  try{
Context ctx = new InitialContext();
if(ctx == null ) 
throw new Exception(Boom - No Context);

DataSource ds = 
  (DataSource)ctx.lookup(
 java:comp/env/jdbc/testDB);

if (ds != null) {
  Connection conn = ds.getConnection();

  if(conn != null)  {
  foo = Got Connection +conn.toString();
  Statement stmt = conn.createStatement();
  ResultSet rst = 
  stmt.executeQuery(
select id, foo, bar from testdata);
  while

RE: DBCP Please Help Get Working Properly

2005-04-08 Thread Jay Burgess
Do you have anything in your Tomcat log files that might help?  If not, you can
bump up the debug levels in server.xml and you might get some more info.  

I also found that adding one of the two following listeners in my server.xml
helped me debug my DBCP problems (I don't remember which one I added, but it
should be obvious):

Listener
 className=org.apache.catalina.mbeans.GlobalResourcesLifecycleListener
 debug=9/
Listener 
 className=org.apache.catalina.core.NamingContextListener
 debug=9/

Jay
Vertical Technology Group
http://www.vtgroup.com/

 

-Original Message-
From: Scott Purcell [mailto:[EMAIL PROTECTED] 
Sent: Friday, April 08, 2005 3:08 PM
To: Tomcat Users List
Subject: DBCP Please Help Get Working Properly

Hello,

I am trying to use the DBCP features of Tomcat 5.5.7. I created a webapp named
testDB and put it under $CATALINA_HOME/webapps/testDB. Then I created a
testDB.xml file under $CATALINA_HOME/conf/Catalina/localhost/testDB.xml.

// here it is
Context path=/testDB docBase=testDB
debug=5 reloadable=true crossContext=true

  Resource name=jdbc/testDB auth=Container type=javax.sql.DataSource
   maxActive=100 maxIdle=30 maxWait=1
   username=javauser password=javadude
driverClassName=com.mysql.jdbc.Driver
   url=jdbc:mysql://localhost:3306/fritest?autoReconnect=true/
/Context

I have been following the notes from: 
http://localhost/tomcat-docs/jndi-datasource-examples-howto.html

I made sure I completed the rest of the tasks.
WEB-INF has the two tag locations, and the resource ref.
eg:

taglib
taglib-uri/WEB-INF/sql.tld/taglib-uri
taglib-location/WEB-INF/sql.tld/taglib-location
/taglib


taglib
taglib-uri/WEB-INF/c.tld/taglib-uri
taglib-location/WEB-INF/c.tld/taglib-location
/taglib

  resource-ref
  descriptionDB Connection/description
  res-ref-namejdbc/testDB/res-ref-name
  res-typejavax.sql.DataSource/res-type
  res-authContainer/res-auth
  /resource-ref

I finally hit my jsp page which is this:
%@ taglib uri=http://java.sun.com/jsp/jstl/sql; prefix=sql %
%@ taglib uri=http://java.sun.com/jsp/jstl/core; prefix=c %

sql:query var=rs dataSource=jdbc/testDB
select id, foo, bar from testdata
/sql:query

html
  head
titleDB Test/title
  /head
  body

  h2Results/h2
  
c:forEach var=row items=${rs.rows}
Foo ${row.foo}br/
Bar ${row.bar}br/
/c:forEach


  /body
/html

And I get no results:

Now I am pretty sure I have all configured. Because if I use a fallback (Tomcat
4.1) code piece I had, I get results using the same settings:

package foo;

import javax.naming.*;
import javax.sql.*;
import java.sql.*;

public class DBTest {

  String foo = Not Connected;
  int bar = -1;

  public void init() {
try{
  Context ctx = new InitialContext();
  if(ctx == null ) 
  throw new Exception(Boom - No Context);

  DataSource ds = 
(DataSource)ctx.lookup(
   java:comp/env/jdbc/testDB);

  if (ds != null) {
Connection conn = ds.getConnection();
  
if(conn != null)  {
foo = Got Connection +conn.toString();
Statement stmt = conn.createStatement();
ResultSet rst = 
stmt.executeQuery(
  select id, foo, bar from testdata);
while(rst.next()) {
   System.out.println(next );
   foo=rst.getString(2);
   bar=rst.getInt(3);
}
conn.close();
}
  }
}catch(Exception e) {
  e.printStackTrace();
}
 }

 public String getFoo() { return foo; }
 public int getBar() { return bar;}
}

And using the above class works all day.

The only difference I see is that the class using a naming import and the jsp
does not. Can anyone help.


Thanks,
Scott









-Original Message-
From: David Smith [mailto:[EMAIL PROTECTED]
Sent: Friday, April 08, 2005 1:14 PM
To: Tomcat Users List
Subject: Re: Add Context Path, Tomcat 5.5.7


Hi.

Take a look at this for where to put Context elements:
http://jakarta.apache.org/tomcat/tomcat-5.5-doc/config/context.html

This is new with Tomcat 5.0 and is continued in Tomcat 5.5

--David

Scott Purcell wrote:

Hello,
 
I am following the information here to add DBCP to my application.
http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-datasource-examples-howto.html
 
I am reading to add the Context path=/DBTest ... from the above docs. The
instructions say to .
 
Configure the JNDI DataSource in Tomcat by adding a declaration for your
resource to $CATALINA_HOME/conf/server.xml.

Add this in between the /Context tag of the examples context and the /Host
tag closing the localhost definition.

 

So cool, I opened up the server.xml, but do not see any existing context or
host tags in it. Here is my server.xml file. Does anyone know where I put the
Context for the DBCP stuff? Thanks,

'!-- Example Server Configuration File --
!-- Note 

Re: DBCP Please Help Get Working Properly

2005-04-08 Thread Robert Harrison
Aren't debug levels in TC 5.5  inactive? Will need to set up log4j.

Bob

On Apr 8, 2005 5:15 PM, Jay Burgess [EMAIL PROTECTED] wrote:
 Do you have anything in your Tomcat log files that might help?  If not, you 
 can
 bump up the debug levels in server.xml and you might get some more info.
 
 I also found that adding one of the two following listeners in my server.xml
 helped me debug my DBCP problems (I don't remember which one I added, but it
 should be obvious):
 
 Listener
  className=org.apache.catalina.mbeans.GlobalResourcesLifecycleListener
  debug=9/
 Listener
  className=org.apache.catalina.core.NamingContextListener
  debug=9/
 
 Jay
 Vertical Technology Group
 http://www.vtgroup.com/
 
 
 -Original Message-
 From: Scott Purcell [mailto:[EMAIL PROTECTED]
 Sent: Friday, April 08, 2005 3:08 PM
 To: Tomcat Users List
 Subject: DBCP Please Help Get Working Properly
 
 Hello,
 
 I am trying to use the DBCP features of Tomcat 5.5.7. I created a webapp named
 testDB and put it under $CATALINA_HOME/webapps/testDB. Then I created a
 testDB.xml file under $CATALINA_HOME/conf/Catalina/localhost/testDB.xml.
 
 // here it is
 Context path=/testDB docBase=testDB
 debug=5 reloadable=true crossContext=true
 
   Resource name=jdbc/testDB auth=Container type=javax.sql.DataSource
maxActive=100 maxIdle=30 maxWait=1
username=javauser password=javadude
 driverClassName=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:3306/fritest?autoReconnect=true/
 /Context
 
 I have been following the notes from:
 http://localhost/tomcat-docs/jndi-datasource-examples-howto.html
 
 I made sure I completed the rest of the tasks.
 WEB-INF has the two tag locations, and the resource ref.
 eg:
 
 taglib
 taglib-uri/WEB-INF/sql.tld/taglib-uri
 taglib-location/WEB-INF/sql.tld/taglib-location
 /taglib
 
 taglib
 taglib-uri/WEB-INF/c.tld/taglib-uri
 taglib-location/WEB-INF/c.tld/taglib-location
 /taglib
 
   resource-ref
   descriptionDB Connection/description
   res-ref-namejdbc/testDB/res-ref-name
   res-typejavax.sql.DataSource/res-type
   res-authContainer/res-auth
   /resource-ref
 
 I finally hit my jsp page which is this:
 %@ taglib uri=http://java.sun.com/jsp/jstl/sql; prefix=sql %
 %@ taglib uri=http://java.sun.com/jsp/jstl/core; prefix=c %
 
 sql:query var=rs dataSource=jdbc/testDB
 select id, foo, bar from testdata
 /sql:query
 
 html
   head
 titleDB Test/title
   /head
   body
 
   h2Results/h2
 
 c:forEach var=row items=${rs.rows}
 Foo ${row.foo}br/
 Bar ${row.bar}br/
 /c:forEach
 
   /body
 /html
 
 And I get no results:
 
 Now I am pretty sure I have all configured. Because if I use a fallback 
 (Tomcat
 4.1) code piece I had, I get results using the same settings:
 
 package foo;
 
 import javax.naming.*;
 import javax.sql.*;
 import java.sql.*;
 
 public class DBTest {
 
   String foo = Not Connected;
   int bar = -1;
 
   public void init() {
 try{
   Context ctx = new InitialContext();
   if(ctx == null )
   throw new Exception(Boom - No Context);
 
   DataSource ds =
 (DataSource)ctx.lookup(
java:comp/env/jdbc/testDB);
 
   if (ds != null) {
 Connection conn = ds.getConnection();
 
 if(conn != null)  {
 foo = Got Connection +conn.toString();
 Statement stmt = conn.createStatement();
 ResultSet rst =
 stmt.executeQuery(
   select id, foo, bar from testdata);
 while(rst.next()) {
System.out.println(next );
foo=rst.getString(2);
bar=rst.getInt(3);
 }
 conn.close();
 }
   }
 }catch(Exception e) {
   e.printStackTrace();
 }
  }
 
  public String getFoo() { return foo; }
  public int getBar() { return bar;}
 }
 
 And using the above class works all day.
 
 The only difference I see is that the class using a naming import and the 
 jsp
 does not. Can anyone help.
 
 Thanks,
 Scott
 
 -Original Message-
 From: David Smith [mailto:[EMAIL PROTECTED]
 Sent: Friday, April 08, 2005 1:14 PM
 To: Tomcat Users List
 Subject: Re: Add Context Path, Tomcat 5.5.7
 
 Hi.
 
 Take a look at this for where to put Context elements:
 http://jakarta.apache.org/tomcat/tomcat-5.5-doc/config/context.html
 
 This is new with Tomcat 5.0 and is continued in Tomcat 5.5
 
 --David
 
 Scott Purcell wrote:
 
 Hello,
 
 I am following the information here to add DBCP to my application.
 http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-datasource-examples-howto.html
 
 I am reading to add the Context path=/DBTest ... from the above docs. The
 instructions say to .
 
 Configure the JNDI DataSource in Tomcat by adding a declaration for your
 resource to $CATALINA_HOME/conf/server.xml.
 
 Add this in between the /Context tag of the examples context and the 
 /Host
 tag 

RE: DBCP Please Help Get Working Properly

2005-04-08 Thread Jay Burgess
My apologies, we're using 5.0.x and I hadn't realized they went away.  But maybe
the logs still will provide some useful info?

Jay
Vertical Technology Group
http://www.vtgroup.com/


 

-Original Message-
From: Robert Harrison [mailto:[EMAIL PROTECTED] 
Sent: Friday, April 08, 2005 4:20 PM
To: Tomcat Users List
Subject: Re: DBCP Please Help Get Working Properly

Aren't debug levels in TC 5.5  inactive? Will need to set up log4j.

Bob

On Apr 8, 2005 5:15 PM, Jay Burgess [EMAIL PROTECTED] wrote:
 Do you have anything in your Tomcat log files that might help?  If not, you 
 can
 bump up the debug levels in server.xml and you might get some more info.
 
 I also found that adding one of the two following listeners in my server.xml
 helped me debug my DBCP problems (I don't remember which one I added, but it
 should be obvious):
 
 Listener
  className=org.apache.catalina.mbeans.GlobalResourcesLifecycleListener
  debug=9/
 Listener
  className=org.apache.catalina.core.NamingContextListener
  debug=9/
 
 Jay
 Vertical Technology Group
 http://www.vtgroup.com/
 
 
 -Original Message-
 From: Scott Purcell [mailto:[EMAIL PROTECTED]
 Sent: Friday, April 08, 2005 3:08 PM
 To: Tomcat Users List
 Subject: DBCP Please Help Get Working Properly
 
 Hello,
 
 I am trying to use the DBCP features of Tomcat 5.5.7. I created a webapp named
 testDB and put it under $CATALINA_HOME/webapps/testDB. Then I created a
 testDB.xml file under $CATALINA_HOME/conf/Catalina/localhost/testDB.xml.
 
 // here it is
 Context path=/testDB docBase=testDB
 debug=5 reloadable=true crossContext=true
 
   Resource name=jdbc/testDB auth=Container type=javax.sql.DataSource
maxActive=100 maxIdle=30 maxWait=1
username=javauser password=javadude
 driverClassName=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:3306/fritest?autoReconnect=true/
 /Context
 
 I have been following the notes from:
 http://localhost/tomcat-docs/jndi-datasource-examples-howto.html
 
 I made sure I completed the rest of the tasks.
 WEB-INF has the two tag locations, and the resource ref.
 eg:
 
 taglib
 taglib-uri/WEB-INF/sql.tld/taglib-uri
 taglib-location/WEB-INF/sql.tld/taglib-location
 /taglib
 
 taglib
 taglib-uri/WEB-INF/c.tld/taglib-uri
 taglib-location/WEB-INF/c.tld/taglib-location
 /taglib
 
   resource-ref
   descriptionDB Connection/description
   res-ref-namejdbc/testDB/res-ref-name
   res-typejavax.sql.DataSource/res-type
   res-authContainer/res-auth
   /resource-ref
 
 I finally hit my jsp page which is this:
 %@ taglib uri=http://java.sun.com/jsp/jstl/sql; prefix=sql %
 %@ taglib uri=http://java.sun.com/jsp/jstl/core; prefix=c %
 
 sql:query var=rs dataSource=jdbc/testDB
 select id, foo, bar from testdata
 /sql:query
 
 html
   head
 titleDB Test/title
   /head
   body
 
   h2Results/h2
 
 c:forEach var=row items=${rs.rows}
 Foo ${row.foo}br/
 Bar ${row.bar}br/
 /c:forEach
 
   /body
 /html
 
 And I get no results:
 
 Now I am pretty sure I have all configured. Because if I use a fallback 
 (Tomcat
 4.1) code piece I had, I get results using the same settings:
 
 package foo;
 
 import javax.naming.*;
 import javax.sql.*;
 import java.sql.*;
 
 public class DBTest {
 
   String foo = Not Connected;
   int bar = -1;
 
   public void init() {
 try{
   Context ctx = new InitialContext();
   if(ctx == null )
   throw new Exception(Boom - No Context);
 
   DataSource ds =
 (DataSource)ctx.lookup(
java:comp/env/jdbc/testDB);
 
   if (ds != null) {
 Connection conn = ds.getConnection();
 
 if(conn != null)  {
 foo = Got Connection +conn.toString();
 Statement stmt = conn.createStatement();
 ResultSet rst =
 stmt.executeQuery(
   select id, foo, bar from testdata);
 while(rst.next()) {
System.out.println(next );
foo=rst.getString(2);
bar=rst.getInt(3);
 }
 conn.close();
 }
   }
 }catch(Exception e) {
   e.printStackTrace();
 }
  }
 
  public String getFoo() { return foo; }
  public int getBar() { return bar;}
 }
 
 And using the above class works all day.
 
 The only difference I see is that the class using a naming import and the 
 jsp
 does not. Can anyone help.
 
 Thanks,
 Scott
 
 -Original Message-
 From: David Smith [mailto:[EMAIL PROTECTED]
 Sent: Friday, April 08, 2005 1:14 PM
 To: Tomcat Users List
 Subject: Re: Add Context Path, Tomcat 5.5.7
 
 Hi.
 
 Take a look at this for where to put Context elements:
 http://jakarta.apache.org/tomcat/tomcat-5.5-doc/config/context.html
 
 This is new with Tomcat 5.0 and is continued in Tomcat 5.5
 
 --David
 
 Scott Purcell wrote:
 
 Hello,
 
 I am following the information here to add DBCP to my application.

http