Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Oracle: Automatically enable support TNSNames aliases if TNS_ADMIN is set #1806

Closed
cdavid15 opened this issue Oct 25, 2017 · 4 comments
Closed

Oracle: Automatically enable support TNSNames aliases if TNS_ADMIN is set #1806

cdavid15 opened this issue Oct 25, 2017 · 4 comments

Comments

@cdavid15
Copy link
Contributor

@cdavid15 cdavid15 commented Oct 25, 2017

What version of Flyway are you using?

4.2.0

Which client are you using? (Command-line, Java API, Maven plugin, Gradle plugin, SBT plugin, ANT tasks)

Command Line

What database are you using (type & version)?

Oracle XE 11.2
Oracle Enterprise 12c

What operating system are you using?

Windows 10

What did you do?

(Please include the content causing the issue, any relevant configuration settings, and the command you ran)

Tried connecting to database using TNSNames within the database connection string url as follows:

jdbc:oracle:thin:@LOCAL_ORCL

Which is a valid connection string as per the Oracle documentation:

http://docs.oracle.com/cd/B19306_01/java.102/b14355/urls.htm#BEIJFHHB

The command I ran was:

flyway info -configFile=conf/flyway-dev.conf

With the configuration file as follows:

flyway.url=jdbc:oracle:thin:@LOCAL_ORCL
flyway.user=TEST
flyway.password=TEST
flyway.locations=filesystem:./sql/common,filesystem:./sql/dev
flyway.installedBy=FlywayDB Migration
flyway.table=__DB_MIGRATIONS
What did you expect to see?

Successful connection to the Database similar to the following:

Flyway 4.2.0 by Boxfuse

Database: jdbc:oracle:thin:@LOCAL_ORCL (Oracle 12.1)
What did you see instead?
Flyway 4.2.0 by Boxfuse

ERROR:
Unable to obtain Jdbc connection from DataSource (jdbc:oracle:thin:@LOCAL_ORCL) for user 'TEST': IO Error: Unknown host specified
----------------------------------------------------------------------------------------------------------------------------------------
SQL State  : 08006
Error Code : 17002
Message    : IO Error: Unknown host specified

I have a local fix and have successfully been using it against Oracle Enterprise 12c Database and will submit a pull request in the coming days once I have made the documentation changes.

@PeeZu
Copy link

@PeeZu PeeZu commented Oct 25, 2017

Hello,

According to Oracle documentation:

When using TNSNames with the JDBC Thin driver, you must set the oracle.net.tns_admin property to the directory that contains your tnsnames.ora file.

Try with:

flyway info -configFile=conf/flyway-dev.conf -Doracle.net.tns_admin=/directory/that/contains/tnsnames/file

@cdavid15
Copy link
Contributor Author

@cdavid15 cdavid15 commented Oct 25, 2017

Yeah that's the change I have made although the flyway command line executable automatically picks up the path based on the TNS_ADMIN environmental variable and automatically passes the JVM property in.

master...cdavid15:master

@axelfontaine axelfontaine added this to the Flyway 5.0.0 milestone Nov 13, 2017
@axelfontaine axelfontaine changed the title Command Line unable to connect to Oracle Database using TNSNames Alias Oracle: Automatically enable support TNSNames aliases if TNS_ADMIN is set Nov 13, 2017
axelfontaine added a commit to flyway/flywaydb.org that referenced this issue Nov 13, 2017
@axelfontaine
Copy link
Contributor

@axelfontaine axelfontaine commented Nov 13, 2017

Thank you very much for the suggestion. I really liked the idea of making it automatic and ending up adding this TNS_ADMIN autodetection to the core to make it available to all clients.

@cdavid15
Copy link
Contributor Author

@cdavid15 cdavid15 commented Nov 13, 2017

Excellent - it's definitely better suited at the core library level. Not the biggest of changes but a very useful one to those using Oracle databases.

axelfontaine added a commit that referenced this issue Apr 10, 2018
… does not work correctly
dohrayme pushed a commit to dohrayme/flyway that referenced this issue Feb 3, 2020
dohrayme pushed a commit to dohrayme/flyway that referenced this issue Feb 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

3 participants
You can’t perform that action at this time.