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

Breadcrumb

more

Connor and Chris don't just spend all day on AskTOM. You can also catch regular content via Connor's blog and Chris's blog. Or if video is more your thing, check out Connor's latest video and Chris's latest video from their Youtube channels. And of course, keep up to date with AskTOM via the official twitter account.

Question and Answer

Connor McDonald

Thanks for the question, Sunny.

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

Answered by: Connor McDonald - Last updated: March 16, 2017 - 1:15 am UTC

Category: Database - Version: 11g2

Viewed 10K+ times! This question is

Whilst you are here, check out some content from the AskTom team: Just one more week

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 we 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.

and you rated our response

  (12 ratings)

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

Reviews

June 16, 2016 - 2:26 pm UTC

Reviewer: Alen

In connection string at client side where is it give a location of oracle wallet?
Chris Saxon

Followup  

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)))

June 19, 2016 - 6:49 pm UTC

Reviewer: A reader

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

Followup  

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

June 20, 2016 - 7:45 am UTC

Reviewer: A reader

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

Followup  

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/


June 21, 2016 - 3:15 pm UTC

Reviewer: A reader

Suppose we have multiple wallet then how to define a path all wallet location?
Chris Saxon

Followup  

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.

June 22, 2016 - 5:47 am UTC

Reviewer: A reader

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.

June 22, 2016 - 6:28 am UTC

Reviewer: Raj

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

Followup  

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"



June 23, 2016 - 8:59 am UTC

Reviewer: Raj

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

Followup  

June 23, 2016 - 11:05 am UTC

wallets are client side

June 24, 2016 - 8:38 am UTC

Reviewer: Raj

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

Connor McDonald

Followup  

June 25, 2016 - 3:08 am UTC

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

June 30, 2016 - 8:00 pm UTC

Reviewer: A reader

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

Followup  

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.


July 19, 2016 - 6:41 am UTC

Reviewer: A reader

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

use of wallet

March 14, 2017 - 10:44 am UTC

Reviewer: A reader

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

Followup  

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=....

March 15, 2017 - 8:02 am UTC

Reviewer: G.G

invalid username and password with help of oracle wallet?
when and why happen?
Connor McDonald

Followup  

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.