chrix75

chrix75

Connection to Oracle DB

Hi,

I continue my Elixir exploration and now I’m trying to fetch data from our databases that are Oracle DB.
I’ve found I must use the Erlang :odbc module and pass through ODBC connection.

I’ve installed the Oracle ODBC driver and set a Data Source but when I try to connect, that fails.

Below my actions and their results:

iex(18)> :odbc.start()
:ok
iex(19)> {ok, ref} = :odbc.connect('DSN=SIRENE_REC;UID=account;PWD=the_password', [])

13:25:21.953 [error] [79, 68, 66, 67, 58, 32, 114, 101, 99, 101, 105, 118, 101, 100, 32, 117, 110, 101, 120, 112, 101, 99, 116, 101, 100, 32, 105, 110, 102, 111, 58, 32, [123, ['tcp_closed', 44, '#Port<0.1505>'], 125], '\n'] {:error, :connection_closed}

13:25:21.954 [error] GenServer #PID<0.125.0> terminating
** (stop) {:port_exit, :collecting_of_driver_information_faild} Last message: {#Port<0.1503>, {:exit_status, 23}} State: {:state, #Port<0.1503>, {#PID<0.81.0>, #Reference<0.1271860022.1836056577.135740>}, #PID<0.81.0>, :undefined, :on, :undefined, :undefined, :on, :connecting, :undefined, 0, [#Port<0.1501>, #Port<0.1502>], #Port<0.1504>, #Port<0.1505>}

For my noob level, I’m lost :blush:

First Post!

NobbZ

NobbZ

Have you done the prechecks from the Erlang ODBC Guide?

In the getting started section there are some things listed to consider and make sure first:

  • The first thing you need to do, is to make sure you have an ODBC driver installed for the database that you want to access. Both the client machine where you plan to run your erlang node and the server machine running the database needs the the ODBC driver. (In some cases the client and the server may be the same machine).
    *Secondly you might need to set environment variables and paths to appropriate values. This may differ a lot between different os’s, databases and ODBC drivers. This is a configuration problem related to the third party product and hence we can not give you a standard solution in this guide.
  • The Erlang ODBC application consists of both Erlang and C code. The C code is delivered as a precompiled executable for windows, solaris and linux (SLES10) in the commercial build. In the open source distribution it is built the same way as all other application using configure and make. You may want to provide the the path to your ODBC libraries using --with-odbc=PATH.

The payload of the error, which got mangled in some way (perhaps something in the chain has problem with IO-Lists?) says roughly that there was an unexpected {'tcp_closed', '#Port<0.1505>'}. Further I have to assume that this is printed by some erlang subroutine and therefore 'tcp_closed is an atom. Anyway. It boils down to a closed TCP connection, which may have many reasons, but I’ve not used any ODBC so far.

Therefore I want to ask you if you can access to that database from another program that uses ODBC, does this program see the same set of environment variables as your erlang program? Has your version of erlang been compiled with a proper value for --with-odbc?

Most Liked

OvermindDL1

OvermindDL1

Instead of using ODBC (which kind of sucks), have you thought about using a direct Oracle driver like jamdb_oracle or so?

I personally mount my work Oracle database as a FDW inside my PostgreSQL database. ^.^

OvermindDL1

OvermindDL1

All the lower-case j prefixes make me think java. You could always write a Java Erlang node (the java api comes with the erlang distribution) for Elixir to talk to. ^.^

Where Next?

Popular in Questions Top

vegabook
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New

Other popular topics Top

Qqwy
Update: How to use the Blogs &amp; Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3271 131117 1222
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 31586 112
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 40165 209
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New

We're in Beta

About us Mission Statement