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 1058735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:04:03+00:00 2026-05-16T18:04:03+00:00

My existing web application gets database pooling parameters from context. Now, I’m developing a

  • 0

My existing web application gets database pooling parameters from context.
Now, I’m developing a new web service to be deployed as a separate application, but using the previous database.

In this new web service application, I am not using any servlet, as well as JSPs. They’ll just be a collection of service classes. In such a case, how do I get the context parameters?

In the earlier case when I’m using a servlet, my context is as below:

<?xml version="1.0" encoding="UTF-8"?>
<Context antiResourceLocking="false" privileged="true" >
 <Resource 
    name="jdbc/NetmarketDB"
    auth="Container"
    type="javax.sql.DataSource"
    removeAbandoned="true"
    removeAbandonedTimeout="30"
    maxActive="100"
    maxIdle="30"
    maxWait="1000"
    username="root"
    password="xxxxxxxx"
    driverClassName="com.mysql.jdbc.Driver"
    url="jdbc:mysql://localhost:3306/netmarket"/>
</Context>

… and I get the context from a servlet or JSP as below:

Connection conn = MySqlDB.getDBConnection(getServletContext());

But now that I’m not using any servlet/JSP, I’m confused. Please help me out.

  • 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-16T18:04:04+00:00Added an answer on May 16, 2026 at 6:04 pm

    Even if you don’t have the servlet context as long as you are running inside your web application with the resource definition in your question you should be able to get it using JNDI:

    Context ctx = new InitialContext();
    DataSource ds = (DataSource)ctx.lookup("jdbc/NetmarketDB");
    Connection con = ds.getConnection("root", "xxxxxxxx");
    

    And if you are not running within a web application then do this:

    Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/netmarket", root", "xxxxxxxx");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am enhancing an existing web application and I have created a new database
My Java web application (tomcat) gets all of its data from an SQL database.
A Silverlight-enabled WCF service was added into existing ASP.NET web-application. On attempt to add
I have an existing application that imports data from a web site api into
We have an existing Web application and we want to migrate from a custom
Essentially I added a new Silverlight project into an existing web application (C#) that
I am trying to add a new class to a pre-existing web application in
I am new to Hibernate. We are migrating one of our existing web application
I have a custom HttpModule rewrite engine in an existing web application project that
I want to add a dashboard functionality to an existing java web application, this

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.