RE: FW: [EXT]Re: how to define database resource in just context.xml or server.xml
Yeah I like the idea of using the Resourcelink in the context.xml and then keep the defining of that datasource in the server.xml Rick Noel Systems Programmer | Westwood One rn...@westwoodone.com -Original Message- From: Christopher Schultz Sent: Friday, March 29, 2024 2:23 PM To: users@tomcat.apache.org Subject: Re: FW: [EXT]Re: how to define database resource in just context.xml or server.xml Rick, On 3/29/24 14:05, Rick Noel wrote: > Chris, > > I found I could use a ResourceLink element and put it in my context.xml file. > The name in that ResourceLink is the name of resource that I have fully > defined in my server.xml. > Sot the context.xml points to the fully define resource which is in my > server.xml That's definitely a possibility as well. I work on a small team and so separating the JDBC definition from the link doesn't make much sense so we don't do it. We also don't like polluting our server.xml file so everything goes into META-INF/context.xml. You really should never change CATALINA_BASE/conf/context.xml, though. -chris > So snippet from my context.xml file is. > > > > > > > > name="jdbc/app-pool" > global="jdbc/app-pool" >type="javax.sql.DataSource" /> > > > And snippet from my server.xml is. > > > > >type="javax.sql.DataSource" > driverClassName="org.postgresql.Driver" > url="jdbc:postgresql://x" > username="x" password="xx" > maxTotal="30" maxIdle="30" maxWaitMillis="-1" > removeAbandonedOnBorrow="true" > removeAbandonedTimeout="90" > testOnBorrow="true" validationQuery="select 1" > validationQueryTimeout="3" > testWhileIdle="true" > timeBetweenEvictionRunsMillis="6" > testOnReturn="true" /> > > > > Rick Noel > Systems Programmer | Westwood One > rn...@westwoodone.com > > -Original Message- > From: Rick Noel > Sent: Friday, March 29, 2024 11:57 AM > To: Tomcat Users List > Subject: RE: [EXT]Re: how to define database resource in just > context.xml or server.xml > > If have the resource defined in > CATALINA_BASE/conf/context.xml > And > CATALINA_BASE/conf/server.xml > > Rick Noel > Systems Programmer | Westwood One > rn...@westwoodone.com > > -Original Message- > From: Christopher Schultz > Sent: Friday, March 29, 2024 11:47 AM > To: users@tomcat.apache.org > Subject: [EXT]Re: how to define database resource in just context.xml > or server.xml > > Rick, > > On 3/29/24 09:48, Rick Noel wrote: >> Can someone tell me why I need to have my database source defined in >> both my context.xml and server.xml? I thought we are suppose to >> define it in only one location? > It's definitely not a requirement to specify it in both places. > >> I can only log into my app if I have it defined in both my >> context.xml and server.xml >> >> Below is my database resource as defined in server.xml.. >> >> I have xxx out postgres URL for security reasons >> >> >> >> >> >>> type="javax.sql.DataSource" >> driverClassName="org.postgresql.Driver" >> url="jdbc:postgresql://xxx" >> username="postgres" >> password="postgres4now" >> maxTotal="30" maxIdle="30" >> maxWaitMillis="-1" >> removeAbandonedOnBorrow="true" >> removeAbandonedTimeout="90" >> testOnBorrow="true" >> validationQuery="select 1" validationQueryTimeout="3" >> testWhileIdle="true" >> timeBetweenEvictionRunsMillis="6" >> testOnReturn="true" >> /> >> >> >> >> >> >> >> Below is my database resource as defined in context.xml >> >> >> >> >>
Re: FW: [EXT]Re: how to define database resource in just context.xml or server.xml
Rick, On 3/29/24 14:05, Rick Noel wrote: Chris, I found I could use a ResourceLink element and put it in my context.xml file. The name in that ResourceLink is the name of resource that I have fully defined in my server.xml. Sot the context.xml points to the fully define resource which is in my server.xml That's definitely a possibility as well. I work on a small team and so separating the JDBC definition from the link doesn't make much sense so we don't do it. We also don't like polluting our server.xml file so everything goes into META-INF/context.xml. You really should never change CATALINA_BASE/conf/context.xml, though. -chris So snippet from my context.xml file is. name="jdbc/app-pool" global="jdbc/app-pool" type="javax.sql.DataSource" /> And snippet from my server.xml is. Rick Noel Systems Programmer | Westwood One rn...@westwoodone.com -Original Message- From: Rick Noel Sent: Friday, March 29, 2024 11:57 AM To: Tomcat Users List Subject: RE: [EXT]Re: how to define database resource in just context.xml or server.xml If have the resource defined in CATALINA_BASE/conf/context.xml And CATALINA_BASE/conf/server.xml Rick Noel Systems Programmer | Westwood One rn...@westwoodone.com -Original Message- From: Christopher Schultz Sent: Friday, March 29, 2024 11:47 AM To: users@tomcat.apache.org Subject: [EXT]Re: how to define database resource in just context.xml or server.xml Rick, On 3/29/24 09:48, Rick Noel wrote: Can someone tell me why I need to have my database source defined in both my context.xml and server.xml? I thought we are suppose to define it in only one location? It's definitely not a requirement to specify it in both places. I can only log into my app if I have it defined in both my context.xml and server.xml Below is my database resource as defined in server.xml.. I have xxx out postgres URL for security reasons Below is my database resource as defined in context.xml Which context.xml are you talking about? The one in CATALINA_BASE/context.xml or the one in your application's META-INF/context.xml? Have you defined your in CATALINA_BASE/conf/server.xml, or are you using only META-INF/context.xml? -chris - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you know the sender and you are sure the content is safe. Please report the message using the Report Message feature in your email client if you believe the email is suspicious. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org