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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:57:26+00:00 2026-05-26T02:57:26+00:00

I am trying to access sqlite.db file in my java web app. i can

  • 0

I am trying to access sqlite.db file in my java web app.
i can access it with absolute path, but now i want to access it with my webapps relative path.
My context.xml looks like

<Context antiJARLocking="true" path="/webappServer">
    <Resource name="jdbc/myDB" auth="Container" 
    type="javax.sql.DataSource" maxActive="100" maxIdle="30" maxWait="1000"
    driverClassName="org.sqlite.JDBC"
    url="jdbc:sqlite:/db/sqlite.db" />
</Context>

and i call for the connection in my java class

Context initContext = new InitialContext();
Context envContext  = (Context) initContext.lookup("java:/comp/env");
DataSource ds = (DataSource) envContext.lookup("jdbc/myDB");
Connection conn = ds.getConnection();

my sqlite location is in C:\db\sqlite.db but now i want to move it so i can call my sqlite connection with something like localhost/mysqlite.db
is it possible ? what should i do to achieve it ?

Thanks !

P.S. Im new to java web app. so any help will be very useful

  • 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-26T02:57:26+00:00Added an answer on May 26, 2026 at 2:57 am

    There are 2 different ways of doing so:

    1. Define the datasource outside your webapps Context.xml inside Tomcat’s own Context.xml and modify it according to the needs of the different servers. One-time configuration on each server required.
    2. Solve the problem during your build process. Create different Context.xml files for all the environments you need, e.g. Context_prod.xml. During the build process identify the file you need and place it in your webapp.

    Those are the 2 approaches I am aware of.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to access my web app built with rails. But when I type
Im trying to access a web service from a remote computer. I managed to
I'm trying to access the Reporting Services via Web Services in my Visual Studio
I'm programming a simple customer-information management software now with SQLite. One exe file, one
I'm trying to use SQLite's C API to open a database and access some
I'm trying to access a SpatiaLite from C# using System.Data.SQLite provider. When I try
What I'm trying to do is access an SQLite database, which is on a
This is the error I get while trying to access a sqlite database from
I am trying to access and change a array from a different class file.
I am trying to directly import an SQL file from a SQLite database into

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.