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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:19:05+00:00 2026-06-15T06:19:05+00:00

Hi I’m new in java/jsp developing. I’m trying to connect to database depending on

  • 0

Hi I’m new in java/jsp developing.

I’m trying to connect to database depending on parameter that jsp file receives from previous page.
My program works if i connect to single DB like

 try {
        InputStream in = getServletContext().getResourceAsStream("/WEB-INF/db.properties");
        properties.load(in);
        connString = properties.getProperty("db_conn").toString();
        connUser = properties.getProperty("db_user").toString();
        connPass = properties.getProperty("db_pass").toString();
        bPath = properties.getProperty("exec_path").toString();
        in.close();
      } catch (IOException ex) {
        System.out.println(ex);
      }

and db.properties file contains

      db_conn=jdbc:oracle:thin:@33.333.3.33:3333:DKSE1
      db_user=guest
      db_pass=guestpw

My attempt:

 String userinfo = request.getParameter("userinfo");
 try {
        InputStream in = getServletContext().getResourceAsStream("/WEB-INF/db.properties");
        properties.load(in);
        db_conn = userinfo + "_conn";
        db_user = userinfo + "_user";
        db_pass = userinfo + "_pass";
        connString = properties.getProperty(db_conn).toString();
        connUser = properties.getProperty(db_user).toString();
        connPass = properties.getProperty(db_pass).toString();
        bPath = properties.getProperty("exec_path").toString();
        in.close();
      } catch (IOException ex) {
        System.out.println(ex);
      }

      try {
        // --- Required database stuff ---
        DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
        Connection conn = DriverManager.getConnection(connString, connUser, connPass);
        Statement stmt = conn.createStatement();
        More codes....
       }

db.properties

       guest_conn=jdbc:oracle:thin:@33.333.3.33:3333:DKSE1
       guest_user=guest
       guest_pass=guestpw

       user_conn=jdbc:oracle:thin@11.222.3.33:4444:ESMZ1
       user_user=user
       user_pass=upw1

       user1_conn=jdbc:oracle:thin@11.11.1.11:1111:GEPD1
       user1_user=user1
       user1_pass=upw1 

       batch_exec_path = ${SERVER_DIR}

Stacktrace

Nov 30, 2012 9:03:55 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [jsp] in context with path [/dashboard] threw exception [An exception occurred processing JSP page /alpharunBatch.jsp at line 106

103:             db_conn = userinfo + "_conn";
104:             db_user = userinfo + "_user";
105:             db_pass = userinfo + "_pass";
106:             connString = properties.getProperty(db_conn).toString();
107:             connUser = properties.getProperty(db_user).toString();
108:             connPass = properties.getProperty(db_pass).toString();
109:             bPath = properties.getProperty("exec_path").toString();


Stacktrace:] with root cause
java.lang.NullPointerException
    at org.apache.jsp.alpharunBatch_jsp._jspService(alpharun_jsp.java:192)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:999)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

Am i doing something fundamentally wrong?
Thanks for your help!

  • 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-06-15T06:19:06+00:00Added an answer on June 15, 2026 at 6:19 am

    try following for test:

    change that

    InputStream in = getServletContext().getResourceAsStream("/WEB-INF/db.properties");
    

    to

    InputStream in = getServletContext().getResourceAsStream("db.properties");
    

    and put your properties in the classpath folder(src)

    Furthermore change

    properties.getProperty("exec_path").toString();
    

    to

    properties.getProperty("batch_exec_path").toString();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want use html5's new tag to play a wav file (currently only supported
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a view passing on information from a database: def serve_article(request, id): served_article
I have a reasonable size flat file database of text documents mostly saved in
I'm trying to create an if statement in PHP that prevents a single post
Let's say I'm outputting a post title and in our database, it's Hello Y’all
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example

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.