Reputation: 21
I am facing an issue while trying to establish JDBC connectivity to Oracle Database using VBscript code in UFT 12.02. Tried installing Oracle Driver for RDB Thin as well as Oracle 11g Client.
Error displayed is :
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
OR
TNS adaptor not found
Connection string used is :
Set con= CreateObject("ADODB.Connection")
strConnectionString = "DRIVER=oracle.jdbc.OracleDriver;URL=jdbc:oracle:thin:@<HOST NAME>:1521:TEMPdatabase;uid=username;pwd=password"
strConnectionString= "DRIVER={Oracle Driver for RDB Thin};URL=jdbc:oracle:thin:@<HOST NAME>:1521:TEMPdatabase;uid=username;pwd=password"
Also note that I am able to access the DB manually through DBVisualizer by creating a new Driver using Tools>Driver Manager>Create Driver and linking it to rdbthin.jar file from local drive
Please help me out with this issue
Upvotes: 1
Views: 3070
Reputation: 65
You can connect to Oracle DB using ODBC connectivity. If your machine is 64 bit and if you want to connect to Oracle DB then you need to install both 64 bit and 32 bit oracle clients on your machine. First 64 bit then 32 bit. You need to add the DSN to 32bit ODBC data source. You also need to connection details in your tnsnames.ora file in both 64 and 32 bit oracle clients. you can find this file in this path after oracle client installation. C:\app\mymachine\product\11.2.0\client_1\network\admin\tnsnames.ora
Here is the sample script to connect to Oracle DB,
Set Con = CreateObject("adodb.connection")
Set rs = CreateObject("adodb.recordset")
Con.Open "DSN="DsnName";Uid="user_id";Pwd="password";"
rs.Open sql, Con
Reporter.ReportEvent micDone ,"DB Function", sql
con.Close
Set con = Nothing
Set rs = Nothing
The DsnName in the function should be same as the DSN Name you add in the ODBC data source.
Upvotes: 1