FAQ

[OpenEJB-dev] Datasource configuration for OS Authentication using Oracle 10g

Gopakumar
Jan 5, 2011 at 4:33 pm
I am facing an issue while creating datasoure in openejb server. I need to
connect to external database (oracle 10g) through os authentication. From
command prompt I am able to connect to database without any problem. command
used like
sqlplus : connect /@testdb - connected ok.
For datasource creation, I dont want to provide user id, password for db
connection. is this possible in openejb?

I tried using a standalone java program by passing the url and user id,it is
connecting the database.

String url = "jdbc:oracle:thin:@localhost:1521:xe";
Properties props = new Properties();
props.put(OracleConnection.CONNECTION_PROPERTY_THIN_VSESSION_OSUSER,
"ASIAPACIFIC\\A162152");
props.put(OracleConnection.CONNECTION_PROPERTY_THIN_VSESSION_OSUSER,
"ASIAPACIFIC\\A162152");*/
Connection conn = DriverManager.getConnection(url, props);

Could any one please tell me how to create datasource in this scenario.

Thanks in advance.

--
View this message in context: http://openejb.979440.n4.nabble.com/Datasource-configuration-for-OS-Authentication-using-Oracle-10g-tp3174875p3174875.html
Sent from the OpenEJB Dev mailing list archive at Nabble.com.
reply

Search Discussions

1 response

  • Andy at Jan 6, 2011 at 8:50 am

    On 05.01.2011 07:16, gopakumar wrote:
    I am facing an issue while creating datasoure in openejb server. I need to
    connect to external database (oracle 10g) through os authentication. From
    command prompt I am able to connect to database without any problem. command
    used like
    sqlplus : connect /@testdb - connected ok.
    For datasource creation, I dont want to provide user id, password for db
    connection. is this possible in openejb?

    I tried using a standalone java program by passing the url and user id,it is
    connecting the database.

    String url = "jdbc:oracle:thin:@localhost:1521:xe";
    Properties props = new Properties();
    props.put(OracleConnection.CONNECTION_PROPERTY_THIN_VSESSION_OSUSER,
    "ASIAPACIFIC\\A162152");
    props.put(OracleConnection.CONNECTION_PROPERTY_THIN_VSESSION_OSUSER,
    "ASIAPACIFIC\\A162152");*/
    Connection conn = DriverManager.getConnection(url, props);

    Could any one please tell me how to create datasource in this scenario.

    Thanks in advance.
    Hi,

    Read these links:
    http://openejb.apache.org/3.0/configuring-datasources.html
    http://openejb.apache.org/3.0/common-datasource-configurations.html

    Then what you'll need to do is find out the real property names for properties you want to set, so have a look here:
    http://download.oracle.com/docs/cd/E11882_01/appdev.112/e13995/constant-values.htm

    Then you just define them in the openejb.xml data source definition

    <Resource id="MyDataSourceName" type="DataSource">
    JdbcDriver oracle.jdbc.OracleDriver
    JdbcUrl jdbc:oracle:thin:@localhost:1521:xe
    name1 value1
    name2 value2
    etc...
    </Resource>

    You can then lookup the data source like so:

    DataSource dataSource = (DataSource) new InitialContext().lookup("java:comp/env/MyDataSourceName");

    Hope this puts you on the right track.

    Andy.

Related Discussions

Discussion Navigation
viewthread | post

2 users in discussion

Gopakumar: 1 post Andy: 1 post