Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6874695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:13:37+00:00 2026-05-27T04:13:37+00:00

This is my context.xml file: … <Resource auth=Container driverClass=net.sourceforge.jtds.jdbc.Driver type=com.jolbox.bonecp.BoneCPDataSource idleMaxAge=240 idleConnectionTestPeriod=60 partitionCount=3 acquireIncrement=1

  • 0

This is my context.xml file:

...
<Resource auth="Container"
          driverClass="net.sourceforge.jtds.jdbc.Driver"
          type="com.jolbox.bonecp.BoneCPDataSource"
          idleMaxAge="240"
          idleConnectionTestPeriod="60"
          partitionCount="3"
          acquireIncrement="1"
          maxConnectionsPerPartition="10"
          minConnectionsPerPartition="3"
          statementsCacheSize="50"
          releaseHelperThreads="4"

          name="jdbc/MyDatasource"
          username="my_username"
          password="my_password"
          factory="org.apache.naming.factory.BeanFactory"
          jdbcUrl="jdbc:jtds:sqlserver://localhost:12345/my_database"
/>
...

I already tried using ServletContext.getResource(java.lang.String) with the name of the resource (“jdbc/MyDatasource”), but Tomcat complains that the name doesn’t begin with a ‘/’. I also tried with “/jdbc/MyDatasource”, but this time it returns null.

I mainly need the jdbcUrl to perform a connection check with the database server (see if the server is online and operational).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T04:13:37+00:00Added an answer on May 27, 2026 at 4:13 am

    Keyword is: JNDI. The resources in the context.xml are not ‘System Resources’ but JNDI Resources.
    Try this:

    InitialContext ic = new InitialContext();
    // that's everything from the context.xml and from the global configuration
    Context xmlContext = (Context) ic.lookup("java:comp/env");
    DataSource myDatasource = (DataSource) xmlContext.lookup("jdbc/MyDatasource");
    
    // now get a connection to see if everything is fine.
    Connection con = ds.getConnection();
    // reaching this point means everything is fine.
    con.close();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following partial spring context xml file: <bean name=template class=org.springframework.jdbc.core.JdbcTemplate> <property name=dataSource
I have the following resource tag in my context.xml file: <?xml version=1.0 encoding=UTF-8?> <Context
Hi, this is the content of my XML file: <?xml version=1.0 encoding=ISO-8859-1?> <mainNode> <sub
Given this XML: <?xml version=1.0 encoding=utf-8?> <content dataType=XML> <item type=Promotion name=Sample Promotion expires=04/01/2009> <![CDATA[
I want to open a file for reading. However, in the context of this
is there a way to reference a .properties file in a spring-context.xml and a
Is it possible to define a macro in my Spring application context XML file
I'd like to keep Tomcat's context.xml file out of my WAR file's META-INF directory
i have the following context.xml in webapp/META-INF/. This one is used by tomcat to
i have separate xml file which has jdbc , mysql details. Now i don't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.