Parser for tnsnames.ora files

Parser for Oracle tnsnames.ora file configuration

License

License

GroupId

GroupId

com.github.a-langer
ArtifactId

ArtifactId

oraconf
Last Version

Last Version

0.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

Parser for tnsnames.ora files
Parser for Oracle tnsnames.ora file configuration
Project URL

Project URL

https://github.com/a-langer/oraconf
Source Code Management

Source Code Management

https://github.com/a-langer/oraconf

Download oraconf

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.a-langer/oraconf/ -->
<dependency>
    <groupId>com.github.a-langer</groupId>
    <artifactId>oraconf</artifactId>
    <version>0.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.a-langer/oraconf/
implementation 'com.github.a-langer:oraconf:0.0.1'
// https://jarcasting.com/artifacts/com.github.a-langer/oraconf/
implementation ("com.github.a-langer:oraconf:0.0.1")
'com.github.a-langer:oraconf:jar:0.0.1'
<dependency org="com.github.a-langer" name="oraconf" rev="0.0.1">
  <artifact name="oraconf" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.a-langer', module='oraconf', version='0.0.1')
)
libraryDependencies += "com.github.a-langer" % "oraconf" % "0.0.1"
[com.github.a-langer/oraconf "0.0.1"]

Dependencies

test (4)

Group / Artifact Type Version
org.junit.jupiter : junit-jupiter-engine jar 5.6.2
org.junit.vintage : junit-vintage-engine jar 5.6.2
org.mockito : mockito-core jar 3.3.3
com.google.code.gson : gson jar 2.8.6

Project Modules

There are no modules declared in this project.

Build Status license Maven JitPack Maven Central

Parser for tnsnames.ora files

Library oraconf-<version>.jar enables working with files in Oracle configuration format as described by documentation. This project is a fork of oraconf.

Supported features:

  • Parsing tnsnames.ora files.
  • Query a parsed file to retrieve a specific entry.
  • Manipulating the parsed entries.
  • Constructing new entries.
  • Serializing parsed/new entries in a unified format that can be saved back to a file.
  • Export to JSON format (including command line).
  • No dependency on third-party libraries.

Getting the library using Maven

Add this dependency to your pom.xml to reference the library:

<dependency>
    <groupId>com.github.a-langer</groupId>
    <artifactId>oraconf</artifactId>
    <version>0.0.1</version>
</dependency>

Usage

Print all entries in a test.ora tnsnames file:

import java.io.FileNotFoundException;
import java.io.IOException;
import com.github.alanger.oraconf.ConfigurationParameter;
import com.github.alanger.oraconf.ConfigurationFile;
import com.github.alanger.oraconf.Parser;
import com.github.alanger.oraconf.ParameterFile;

public class Main {
    public static void main(String[] args) throws FileNotFoundException, IOException {
        ConfigurationFile cFile = new Parser(new ParameterFile("test.ora")).parse();
        for(ConfigurationParameter cp : cFile.getParameters()) {
            System.out.println( cp.toString() );
        }
    }
}

Parse a tnsnames file and find a specific entry by parameter printing it to stdout:

cFile = new Parser(cFile).parse();
System.out.println(cFile.findParameter(new Parameter("Area52")).toString());

Parse a tnsnames file and find a specific entry by name printing it to stdout:

cFile = new Parser(cFile).parse();
System.out.println(cFile.findParameter("Area52").toString());

Parse a tnsnames file and find a specific entry by name printing it to stdout as JSON:

cFile = new Parser(cFile).parse();
System.out.println(cFile.findParameter("Area52").toJson());

Export to JSON from command line using oraconf-*.jar:

java -jar ./oraconf-*.jar /etc/tns_admin/tnsnames.ora > tnsnames.json

Related resources

Versions

Version
0.0.1