Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6578055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:43:16+00:00 2026-05-25T15:43:16+00:00

I am looking for something similar to the Ant sql task but that will

  • 0

I am looking for something similar to the Ant sql task but that will accept a JDBC url of the format:

jdbc:oracle:thin:@TNS_NAME

One possible approach seems to be to write my own Ant task that uses an OracleDataSource to create the Connection, but is there a way to do this straight in Ant?

EDIT:
Thanks for the responses so far guys. I hope it helps if I elaborate a bit more on the error I’m getting.

My Ant task looks as follows:

<target name="MyTarget" >
    <property name="oracle.net.tns_admin" value="/opt/oracle/product/10.2.0.1/NETWORK/ADMIN" />
    <property name="jdbc.driver" value="ojdbc5.jar" />
    <property name="jdbc.i18n.support" value="orai18n.jar" />
    <property name="jdbc.driver.class" value="oracle.jdbc.OracleDriver" />
    <path id="sql.class.path">
        <pathelement location="${jdbc.driver}" />
        <pathelement location="${jdbc.i18n.support}" />
    </path>

    <sql driver="${jdbc.driver.class}" url="jdbc:oracle:thin:@THE_TNS_NAME" userid="USER" password="PASSWORD" classpathref="sql.class.path" >
        <![CDATA[
        #SOME ARBITRARY SQL HERE
        ]]>
    </sql>
</target>

This fails with the error:

java.sql.SQLException: Io exception: Unknown host specified

Replacing the url with “jdbc:oracle:thin:@HOST:PORT:INSTANCE” works fine, and I can also tnsping the tns name used above, so I know it’s valid.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T15:43:17+00:00Added an answer on May 25, 2026 at 3:43 pm

    Was just working with this today and stumbled upon the missing piece. The TNS location needs to be set as a system property as indicated here: Oracle thin JDBC to TNS name

    To establish an Oracle thin JDBC connection to a TNS alias (tnsname),
    make sure you pass the oracle.net.tns_admin system property to the JVM.
    Its value should be the directory in which your tnsnames.ora file is
    located. After that, you can just pass the TNS alias in place of the
    host name in the JDBC URL.

    E.g. if you simply try to connect to jdbc:oracle:thin:@MYDB, which
    is in your tnsnames.ora file, you’ll get an SQLException with a detail
    message of Io exception: Unknown host specified. If you fire up the JVM
    with a -Doracle.net.tns_admin=/oracle/10g/NETWORK/ADMIN, or use
    System.setProperty(String,String) after startup, the connection
    will be established successfully.

    After doing this I was able to successfully connect using the TNS alias alone.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am basically looking for something similar but simpler tool like cURL that fetches
I'm looking for something similar to the table creation form from phpmyadmin, but it
I've come to love Amazon's EC2 service and I'm looking for something similar that
I'm looking for something similar to List<T> , that would allow me to have
i am looking for something similar to Organizing GUI code , but for Python
Looking for something similar to Modelmaker that was for Delphi. Showing dependecies of modules.
I'm looking for something similar to the CopyOnWriteSet in Java, a set that supports
I'm looking for something similar to distance_of_time_in_words() but rather than the 'in_words' part I
Instead of the FileSystemWachter Class I am looking something similar that looks when a
I'm looking for something similar to C++'s boost::bind but in C. What I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.