orafile

Java for dealing with Oracle SQL*Net .ora files

License

License

GroupId

GroupId

org.codeswarm
ArtifactId

ArtifactId

orafile
Last Version

Last Version

1.1.1
Release Date

Release Date

Type

Type

jar
Description

Description

orafile
Java for dealing with Oracle SQL*Net .ora files
Project URL

Project URL

https://github.com/codeswarm/orafile
Source Code Management

Source Code Management

https://github.com/codeswarm/orafile

Download orafile

How to add to project

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

Dependencies

compile (1)

Group / Artifact Type Version
org.antlr : antlr-runtime jar 3.0.1

test (2)

Group / Artifact Type Version
commons-io : commons-io jar 2.0.1
org.testng : testng jar 6.2.1

Project Modules

There are no modules declared in this project.

orafile

Java for dealing with Oracle SQL*Net .ora files

Example usage

import edu.gatech.gtri.orafile.*;
import java.util.*;

public class OrafileDemo {

    public static void main(String[] args) throws Exception {

        // The sort of thing you might find in tnsnames.ora
        String tnsFileContent = "TheApplication =\n" +
            "  (ADDRESS = (PROTOCOL = TCP)(HOST = app-server)(PORT = 1521))\n" +
            "  (ADDRESS = (PROTOCOL = TCP)(HOST = app-server)(PORT = 1522))\n" +
            "  (CONNECT_DATA =(SID = banana)(SERVER = dedicated)))";

        // Parse the string.
        OrafileDict tns = Orafile.parse(tnsFileContent);

        System.out.println(tns); /* Output:

        THEAPPLICATION
          ADDRESS
            PROTOCOL: TCP
            HOST: app-server
            PORT: 1521
          ADDRESS
            PROTOCOL: TCP
            HOST: app-server
            PORT: 1522
          CONNECT_DATA
            SID: banana
            SERVER: dedicated
        */

        // Get the entry for "theapplication".
        OrafileVal theapplication = tns.get("theapplication").get(0);

        // Find ADDRESS entries and their HOST, PORT, and SID attributes.
        List<Map<String, String>> values = theapplication
            .findParamAttrs("address", Arrays.asList("host", "port", "sid"));

        System.out.println(values); /* Output:

        [{port=1521, sid=banana, host=app-server}, {port=1522, sid=banana, host=app-server}]
        */

        System.out.println(new OrafileRenderer().renderFile(tns)); /* Output:

        TheApplication =
          (ADDRESS =
            (PROTOCOL = TCP)
            (HOST = app-server)
            (PORT = 1521)
          )
          (ADDRESS =
            (PROTOCOL = TCP)
            (HOST = app-server)
            (PORT = 1522)
          )
          (CONNECT_DATA =
            (SID = banana)
            (SERVER = dedicated)
          )
        */
    }

}

Download

Orafile is available from Maven Central.

<dependency>
  <groupId>edu.gatech.gtri.orafile</groupId>
  <artifactId>orafile</artifactId>
  <version>2.0</version>
</dependency>
org.codeswarm

Codeswarm

Versions

Version
1.1.1
1.1
1.0