Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I connect to an Oracle database from Ant using the tnsname?
    text
    copied!<p>I am looking for something similar to the Ant sql task but that will accept a JDBC url of the format: </p> <blockquote> <p>jdbc:oracle:thin:@TNS_NAME</p> </blockquote> <p>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?</p> <p><strong>EDIT:</strong> Thanks for the responses so far guys. I hope it helps if I elaborate a bit more on the error I'm getting.</p> <p>My Ant task looks as follows:</p> <pre><code>&lt;target name="MyTarget" &gt; &lt;property name="oracle.net.tns_admin" value="/opt/oracle/product/10.2.0.1/NETWORK/ADMIN" /&gt; &lt;property name="jdbc.driver" value="ojdbc5.jar" /&gt; &lt;property name="jdbc.i18n.support" value="orai18n.jar" /&gt; &lt;property name="jdbc.driver.class" value="oracle.jdbc.OracleDriver" /&gt; &lt;path id="sql.class.path"&gt; &lt;pathelement location="${jdbc.driver}" /&gt; &lt;pathelement location="${jdbc.i18n.support}" /&gt; &lt;/path&gt; &lt;sql driver="${jdbc.driver.class}" url="jdbc:oracle:thin:@THE_TNS_NAME" userid="USER" password="PASSWORD" classpathref="sql.class.path" &gt; &lt;![CDATA[ #SOME ARBITRARY SQL HERE ]]&gt; &lt;/sql&gt; &lt;/target&gt; </code></pre> <p>This fails with the error:</p> <blockquote> <p>java.sql.SQLException: Io exception: Unknown host specified</p> </blockquote> <p>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.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload