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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T16:24:00+00:00 2026-05-21T16:24:00+00:00

I am using Spring JdbcTemplate/SimpleJdbcTemplate in combination with an Oracle datasource (oracle.jdbc.pool.OracleDataSource) via JNDI

  • 0

I am using Spring JdbcTemplate/SimpleJdbcTemplate in combination with an Oracle datasource (oracle.jdbc.pool.OracleDataSource) via JNDI lookup. This application is running on Oracle Application Server (OAS) 10.1.3 connecting to an Oracle 11g database.

The database connection that I am making is to an account that has a couple of non-default database roles. I need to enable these roles (probably via the Oracle “set role” command) when the physical connection to the database is established. I don’t see any way to configure the Oracle datasource to issue a SQL command to do this. Because my Java code is using the Spring JDBC classes, it doesn’t deal with opening and closing connections. Does Spring offer some way to run some initialization SQL upon getting a connection?

Datasource definition:

<?xml version = '1.0' encoding = 'windows-1252'?>
<data-sources xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"     xsi:noNamespaceSchemaLocation="http://xmlns.oracle.com/oracleas/schema/data-sources-10_1.xsd">
 <native-data-source data-source-class="oracle.jdbc.pool.OracleDataSource"
                      jndi-name="jdbc/xxx" name="xxx"
                      url="jdbc:oracle:thin:@hostxxx:1541:xxx"
                      password="zzzzz" user="username"/>
</data-sources>

Spring bean definition:

<jee:jndi-lookup id="dataSource" jndi-name="jdbc/xxx" />
  • 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-21T16:24:01+00:00Added an answer on May 21, 2026 at 4:24 pm

    You can always create a proxy for the DateSource and override its getConnection().

    Perhaps even using AOP:

    @Aspect
    public class DataSourceAspect {
        @AfterReturning(value = "execution(* javax.sql.DataSource.getConnection(..))", 
            returning = "c")
        public void afterGetConnection(Connection c) {
            ...
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Spring 1.2.1 and oracle.jdbc.pool.OracleDataSource 10.2.0.3.0 I sometimes get a stack trace like below.
I'm using Spring's support for JDBC. I'd like to use JdbcTemplate (or SimpleJdbcTemplate) to
Hi I am using spring jdbctemplate to invoke an oracle function which takes an
I am new to spring. I am developing a CRUD application using spring jdbc
I am using JDBC (and spring-jdbc's jdbcTemplate) to access my database in a java
I have a Java library where I access the DB via JDBC using Spring's
From the Spring JDBC documentation, I know how to insert a blob using JdbcTemplate
I'm using Spring JdbcTemplate interface for fetching data from a MS SqlServer DB. In
I am using spring/hibernate stand alone application. if i dont configure Transactions i am
I am using spring mvc in my application,when i created user i have to

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.