I'm a beginner to using vb.net, on this issue I want to connect Oracle 12c to my visual basic application. I think everything is correct, and the application can also be run. but when i want to test the connection, my console displays an error Exception thrown: 'System.IO.FileNotFoundException' in Hotel.dll
Here is my code :
Imports Oracle.DataAccess.Client
Public Class Form1
Dim con As New OracleConnection
Dim cmd As New OracleCommand
Dim sql As String
Private Sub btntest_Click(sender As Object, e As EventArgs) Handles btntest.Click
dbAccess()
End Sub
Private Sub dbAccess()
con = New OracleConnection
Try
con.ConnectionString = "Data Source=(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))(CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = pdborcl))); user id=admin;password=admin"
con.Open()
MsgBox("Connection OK")
Catch ex As Exception
MsgBox("Connection Fail")
End Try
End Sub
End Class
Here is the error :
https://i.ibb.co/443qTQ0/Untitled.png
https://i.ibb.co/84D8Rty/Untitledx.png
Connection and commands need to be declared locally in Using blocks in the method where they are used. They contain unmanaged resources which the class releases in a Dispose method. Using blocks close and dispose these objects even if there is an error.
Calling ToString on the Exception should give you more details on the problem.
For connection problems see https://www.connectionstrings.com/oracle-data-provider-for-net-odp-net/
Private OracleConstring As String = "Data Source=(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))(CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = pdborcl))); user id=admin;password=admin"
Private Sub dbAccess()
Using con As New OracleConnection(OracleConstring)
Try
con.Open()
MsgBox("Connection OK")
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Using
End Sub
Related
I try to create a db client with EF that will connect to an Oracle Db through an Oracle Connection Manager proxy. I can reach the db from the client using sqlplus using source_route in the tnsnames.ora file of the client:
orcl_db_with_cman =
(DESCRIPTION =
(SOURCE_ROUTE = YES)
(ADDRESS =
(PROTOCOL = TCP)(HOST = cm_proxy_server)(PORT = 1522)
)
(ADDRESS =
(PROTOCOL = TCP)(HOST = db_server)(PORT = 1521)
)
(CONNECT_DATA = (SERVICE_NAME = orcl_db)
)
)
However, Oracle DB Managed Access Provider does not seem to support the source_route parameter in the connection string Data Source = (Description= (Source_Route=YES..;.
Can Source_Route be defined in an Oracle Provider connection string?
If Source_Route is not an available parameter for Oracle Providers, the Connection Manager proxy could be setup to route the connection.
However, I receive time-out when configuring CM to route:
Listener.ora on Connection Manager server:
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = orcl_db)
(ORACLE_HOME = D:\OraClient\product\19.0.0\client_1)
(SID_NAME = orcl_db)
)
)
LISTENER =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1522))
)
tnsnames.ora on Connection Manager server:
orcl_db =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = db_server)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl_db)
)
)
I want a friend to access to my oracle DB through DBlink. Im new to Databases, so i could not make this work.
I suppose i have to create a listener with my public IP or so. So i used the NET configuration wizard to create a service name. I used the public IP but the wizard throws a timeout when trying to connect. I tried to create a Listener with my public IP in the listener.ora in por 1522 but it did not work eaither
What i have done:
I checked the listener.ora, it has a LISTENER with my local ip (192.168.1.134) and the port is 1521
I checked the tnsnames.ora, it has the same IP and port of the listener.
I made the port forwarding in my router.
I used the wizard to create a Listener with public IP.
I used the wizard to create a service name with public IP address but it cannot connect
TNSNAMES.ORA:
# tnsnames.ora Network Configuration File: D:\Programas\Oracle\NETWORK\ADMIN\tnsnames.ora
# Generated by Oracle configuration tools.
ORACLR_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
(CONNECT_DATA =
(SID = CLRExtProc)
(PRESENTATION = RO)
)
)
LISTENER_ORCL =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.134)(PORT = 1521))
JORGE_ORA_DB =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 190.153.1.32)(PORT = 1522))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.134)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
LISTENER.ORA:
# listener.ora Network Configuration File: D:\Programas\Oracle\NETWORK\ADMIN\listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = CLRExtProc)
(ORACLE_HOME = D:\Programas\Oracle)
(PROGRAM = extproc)
(ENVS = "EXTPROC_DLLS=ONLY:D:\Programas\Oracle\bin\oraclr19.dll")
)
)
REMOTE =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = croquer.ddns.net)(PORT = 1522))
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.134)(PORT = 1521))
)
)
Thank you for your responses!
The solution was quite simple. I created a new inbound and outbound rule in the firewall i both computers. Then it worked for me.
The rules are port type rules for port 1521 (in my case).
I already read other posts about this problem, but mine is not a Hibernate problem, is a connection problem.
I installed Oracle database 12 c on a new machine, but I can't connect my web application to it. I get this error:
Caused by: org.hibernate.HibernateException: Access to
DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
And I'm sure that this problem is just about the connection. The application perfectly works if I try to connect to a MySQL database.
This is my tnsnamesora file
LISTENER_ORCL =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
ORACLR_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
(CONNECT_DATA =
(SID = CLRExtProc)
(PRESENTATION = RO)
)
)
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
These are my connection data:
spring.datasource.url=jdbc:oracle:thin:#localhost:1521/orcl
spring.datasource.username=DB_EXAMPLE
spring.datasource.password=Frema16242 //this is correct
spring.datasource.database-driver=oracle.jdbc.driver.OracleDriver
hibernate.c3p0.preferred_test_query=SELECT 1 FROM DUAL
These are the Oracle services running on my pc.
Of course I'm able to connect to my schema using Toad .
Can you spot what is my error?
I think i had same problem like you. I tried to set connection using datasource. I used sessionFactory with constructor datasource argument. I solved it when i created properties object and i put hibernate.dialect property to it. Next i set this properties on my sessionFactory object.
I have the user name, password, the name of server and name of the database the database and the TNS connection string with the Server name = ABCDE
ABC =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 11.11.111.11)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 11.11.111.12)(PORT = 1521))
(LOAD_BALANCE = yes)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ABC)
)
)
In the URI properties of the comsumer apadper service I am giving the DataSourceName as the servername and the Service Name as given in the TNS connection string ABC. It is not getting connected
ORA-12154: TNS:could not resolve the connect identifier specified
I only have Oracle 8i installed in my system working fine. I can successfully connect using jdbc to it using driverManager but the problem occurs when I am using OracleDataSource to connect to it. It says Oracle not Available. I guess I am doing something wrong in providing the sid.
Part of my code -
OracleDataSource ds = new OracleDataSource();
ds.setDriverType("thin");
ds.setServerName("localhost");
ds.setPortNumber(1521);
ds.setDatabaseName("ORCL0"); // sid
ds.setUser("scott");
ds.setPassword("tiger");
Connection conn = ds.getConnection();
tnsnames.ora entry (part of it) -
ORACLE =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = guddus-comp)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = oracle)
)
)
listener.ora entry (part of it) -
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = C:\oracle\ora92)
(PROGRAM = extproc)
)
(SID_DESC =
(GLOBAL_DBNAME = oracle)
(ORACLE_HOME = C:\oracle\ora92)
(SID_NAME = ORCL0)
)
(SID_DESC =
(GLOBAL_DBNAME = dbabhi)
(ORACLE_HOME = C:\oracle\ora92)
(SID_NAME = DBABHI)
)
)
In my code I'v tried oracle, orcl also in place of ORCL0 but anything other than ORCL0 gives Io exception: Connection refused whereas providing ORCL0 gives Exception - ORA-01034: ORACLE not available.... So I guess ORCL0 is correct but I anticipate some other problem.