Skip to Main Content
  • Questions
  • how to use Connection String in VB.NET using Oracle Wallet ?

Breadcrumb

May 4th

Question and Answer

Connor McDonald

Thanks for the question, Sunny.

Asked: March 21, 2016 - 10:19 am UTC

Last updated: March 16, 2017 - 1:15 am UTC

Version: 11g2

Viewed 10K+ times! This question is

You Asked

In vb.net we could use following connection string but i recently do practical on oracle wallet done successfully in SQL PLUS Tools but main question is i want to use this connection string (username and password and tnsping) using oracle wallet store in a server in vb.net application.

so how to use oracle wallet in vb.net application?


following connection string for vb.net application connect to oracle database.
Dim oradb As String = "Data Source=ORCL10g;User Id=scott;Password=tiger;"

Dim conn As New OracleConnection(oradb) ' VB.NET

and Connor said...

I know in C# .Net, you'll see connection strings like:

"Data Source=ORCL;User ID=/;Min Pool Size=4;Max Pool Size=4"

so I'm assuming you can so the same or similar in vb.net

Hope this helps.

Rating

  (12 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Alen, June 16, 2016 - 2:26 pm UTC

In connection string at client side where is it give a location of oracle wallet?
Chris Saxon
June 17, 2016 - 2:44 am UTC

A typical connection string might look like:

Data Source=MY_SOURCE;User ID=/;Min Pool Size=4;Max Pool Size=20

The location of wallet, is controlled by global or local sqlnet.ora,

WALLET_LOCATION=(SOURCE=(METHOD=FILE)(METHOD_DATA=(DIRECTORY=c:\oracle\wallet)))

A reader, June 19, 2016 - 6:49 pm UTC

in c#.net
Using oracle wallet then
string oradb = "Data Source=wUser1;User ID=/;Min Pool Size=4;Max Pool Size=20";

error is invalid username and password
Chris Saxon
June 20, 2016 - 12:42 am UTC

Firstly - confirm that the wallet has been setup and is configured correctly, so a basic SQL Plus connection should work, ie

sqlplus /@wuser1

A reader, June 20, 2016 - 7:45 am UTC

when i connect to sqlplus /@wUser1 then work fine but connection string in c#.net does not work.
below not work
"Data Source=ORCL;User ID=/;Min Pool Size=4;Max Pool Size=4"
Connor McDonald
June 20, 2016 - 8:49 am UTC

Hold on...is your data source (ie, the tnsnames entry you are using, and its matching wallet entry) "wuser1" or "orcl" ?

ie, make sure all the configuration is lined up, eg

https://connormcdonald.wordpress.com/2015/09/21/connection-shortcuts-with-a-wallet/


A reader, June 21, 2016 - 3:15 pm UTC

Suppose we have multiple wallet then how to define a path all wallet location?
Chris Saxon
June 22, 2016 - 1:28 am UTC

Your TNS_ADMIN environment variable can point to a location where a particular sqlnet.ora will define your wallet.

Or you can have a ".sqlnet.ora" in your home directory, to override the default one.

A reader, June 22, 2016 - 5:47 am UTC

Suppose wallet connection string in sqlnet.ora like
WALLET_LOCATION=(SOURCE=(METHOD=FILE)(METHOD_DATA=(DIRECTORY=c:\oracle\wallet))).
Now can here we create another method_data entry for another directory or nor?
If possible plz demonstrate path.

Raj, June 22, 2016 - 6:28 am UTC

Hii Tom,
I successfully create credential for user1 but I need also set a credential for user2 and user3.

when I create for user1.
using
" mkstore -wrl D:\wallet -createCredential wuser1 user1 user1 "
now i configure for
" mkstore -wrl D:\wallet -createCredential wuser2 user2 user2 "
then says exception like below
Error :-
Create credential Secret Store error occured: oracle.security.pki.OracleSecretSt
oreException: Credential already exists


Now What step perform for user2 credential????

Connor McDonald
June 23, 2016 - 2:14 am UTC

Each credential key is unique, so for example, let's say I want a wallet entry for two different users to the same database. I would do this:

mkstore -wrl c:\oracle\wallet -createCredential MYDB1 scott tiger
mkstore -wrl c:\oracle\wallet -createCredential MYDB2 hr hr

(if I get a "already exists" error with either, it means that MYDB1 or MYDB2 or already in the wallet, you can remove it with -deleteCredential)

Then my tnsnames.ora has an entry for each key,

MYDB1 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = np12)
    )
  )


MYDB2 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = np12)
    )
  )



And then its just a case of connecting with those aliases

C:\Users\comcdona>sqlplus /@mydb1

SQL*Plus: Release 12.1.0.2.0 Production on Thu Jun 23 10:10:05 2016

Copyright (c) 1982, 2014, Oracle.  All rights reserved.

Last Successful login time: Sat Jun 04 2016 11:36:33 +08:00

Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Advanced Analytics
and Real Application Testing options


SQL> sho user
USER is "SCOTT"

SQL> exit

Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Advanced Analytics
and Real Application Testing options

C:\Users\comcdona>sqlplus /@mydb2

SQL*Plus: Release 12.1.0.2.0 Production on Thu Jun 23 10:10:16 2016

Copyright (c) 1982, 2014, Oracle.  All rights reserved.

Last Successful login time: Thu Jun 23 2016 10:08:22 +08:00

Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Advanced Analytics
and Real Application Testing options

SQL> sho user
USER is "HR"



Raj, June 23, 2016 - 8:59 am UTC

I know that change in tnsname.Ora at client side.
Server side sqlnet.Ora
Now main question is suppose I have more than 20 user so to create wallet individual machine or something else.
Connor McDonald
June 23, 2016 - 11:05 am UTC

wallets are client side

Raj, June 24, 2016 - 8:38 am UTC

As per your view,
Suppose we have 20 users then need to configure manually 20 machines for oracle wallet.

Connor McDonald
June 25, 2016 - 3:08 am UTC

Or have a shared location (eg network or NFS drive)

A reader, June 30, 2016 - 8:00 pm UTC

What is main limitation of oracle wallet?

I mean oracle provide secure external password store using oracle wallet and connect just /@tns_alias , why many peoples not used oracle wallet? have a disadavntage?
Connor McDonald
July 01, 2016 - 2:24 am UTC

I dont know of any limitations.

I think people dont use it simple because they are not aware of using it in this way.

They tend to associate wallets only with encryption or other advanced security techniques.


A reader, July 19, 2016 - 6:41 am UTC

Really helpfull me. And I also suggest out orgazation to impplement it.

use of wallet

A reader, March 14, 2017 - 10:44 am UTC

how can i use wallet using export utility like exp.
i don't use exp userid=usernam/password but i want to use wallet credential for export utility.
how it's possible?
Connor McDonald
March 15, 2017 - 3:34 am UTC

See this post

https://connormcdonald.wordpress.com/2015/09/21/connection-shortcuts-with-a-wallet/

for a step by step guide.

Then it will just be

exp userid=/ file=....

G.G, March 15, 2017 - 8:02 am UTC

invalid username and password with help of oracle wallet?
when and why happen?
Connor McDonald
March 16, 2017 - 1:15 am UTC

Generally you get invalid username or password if

a) the username is invalid
b) the password is invalid
c) both are invalid
d) something is wrong in your setup which means the wrong username/password information is being sent.