Oracle - copy table from one schema to another using ant





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







1















I need to copy a table from one oracle schema to another, I can do this by running the following query in schema_one -



create table EMPLOYEES unrecoverable as select * from schema_two.EMPLOYEES;


which works when run using the command line or sql developer.



But the challenge is to execute this using ant script.



I have my ant target as below



<target name="create.tables">
<echo message="creating tables... " />
<sql driver="${db.driver}"
url="${db.url}"
userid="${db.username}"
password="${db.password}"
onerror="abort"
keepformat="yes"
encoding="UTF-8"
>
<transaction>
create table EMPLOYEES unrecoverable as select * from schema_two.EMPLOYEES;

</transaction>
<classpath>
<path refid="database.common.classpath"/>
</classpath>
</sql>
</target>


where db.driver,db.url,db.username and db.password are defined for schema_one.
Running this throws an error as below



I have an entry in tnsnames.ora for the schemas as well.



java.sql.SQLRecoverableException: Listener refused the connection with the following error:
ORA-12514, TNS:listener does not currently know of service requested in connect descriptor

at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:825)
at oracle.jdbc.driver.PhysicalConnection.connect(PhysicalConnection.java:751)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:38)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:593)
at org.apache.tools.ant.taskdefs.JDBCTask.getConnection(JDBCTask.java:366)
at org.apache.tools.ant.taskdefs.SQLExec.getConnection(SQLExec.java:963)
at org.apache.tools.ant.taskdefs.SQLExec.execute(SQLExec.java:628)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1405)
at org.apache.tools.ant.Project.executeTarget(Project.java:1376)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1260)
at org.apache.tools.ant.Main.runBuild(Main.java:857)
at org.apache.tools.ant.Main.startAnt(Main.java:236)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:287)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:113)
Caused by: oracle.net.ns.NetException: Listener refused the connection with the following error:
ORA-12514, TNS:listener does not currently know of service requested in connect descriptor

at oracle.net.ns.NSProtocolStream.negotiateConnection(NSProtocolStream.java:324)
at oracle.net.ns.NSProtocol.connect(NSProtocol.java:287)
at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1963)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:564)
... 22 more









share|improve this question























  • THen your connect string is not being constructed correctly. Are you sure all the properties being referenced are valid?

    – OldProgrammer
    Nov 16 '18 at 18:47













  • Yes they do, if I run a simple query on without schema_two reference ,it runs perfectly fine!

    – xKir
    Nov 16 '18 at 18:52











  • can you re-try using jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(HOST=myhost)(PORT=1521)(PROTOCOL=tcp))(CONNECT_DATA=(SERVICE_NAME=myorcldbservicename))) as db.url. don't forget to change myhost and myorcldbservicename.

    – guleryuz
    Nov 18 '18 at 5:43


















1















I need to copy a table from one oracle schema to another, I can do this by running the following query in schema_one -



create table EMPLOYEES unrecoverable as select * from schema_two.EMPLOYEES;


which works when run using the command line or sql developer.



But the challenge is to execute this using ant script.



I have my ant target as below



<target name="create.tables">
<echo message="creating tables... " />
<sql driver="${db.driver}"
url="${db.url}"
userid="${db.username}"
password="${db.password}"
onerror="abort"
keepformat="yes"
encoding="UTF-8"
>
<transaction>
create table EMPLOYEES unrecoverable as select * from schema_two.EMPLOYEES;

</transaction>
<classpath>
<path refid="database.common.classpath"/>
</classpath>
</sql>
</target>


where db.driver,db.url,db.username and db.password are defined for schema_one.
Running this throws an error as below



I have an entry in tnsnames.ora for the schemas as well.



java.sql.SQLRecoverableException: Listener refused the connection with the following error:
ORA-12514, TNS:listener does not currently know of service requested in connect descriptor

at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:825)
at oracle.jdbc.driver.PhysicalConnection.connect(PhysicalConnection.java:751)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:38)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:593)
at org.apache.tools.ant.taskdefs.JDBCTask.getConnection(JDBCTask.java:366)
at org.apache.tools.ant.taskdefs.SQLExec.getConnection(SQLExec.java:963)
at org.apache.tools.ant.taskdefs.SQLExec.execute(SQLExec.java:628)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1405)
at org.apache.tools.ant.Project.executeTarget(Project.java:1376)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1260)
at org.apache.tools.ant.Main.runBuild(Main.java:857)
at org.apache.tools.ant.Main.startAnt(Main.java:236)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:287)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:113)
Caused by: oracle.net.ns.NetException: Listener refused the connection with the following error:
ORA-12514, TNS:listener does not currently know of service requested in connect descriptor

at oracle.net.ns.NSProtocolStream.negotiateConnection(NSProtocolStream.java:324)
at oracle.net.ns.NSProtocol.connect(NSProtocol.java:287)
at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1963)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:564)
... 22 more









share|improve this question























  • THen your connect string is not being constructed correctly. Are you sure all the properties being referenced are valid?

    – OldProgrammer
    Nov 16 '18 at 18:47













  • Yes they do, if I run a simple query on without schema_two reference ,it runs perfectly fine!

    – xKir
    Nov 16 '18 at 18:52











  • can you re-try using jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(HOST=myhost)(PORT=1521)(PROTOCOL=tcp))(CONNECT_DATA=(SERVICE_NAME=myorcldbservicename))) as db.url. don't forget to change myhost and myorcldbservicename.

    – guleryuz
    Nov 18 '18 at 5:43














1












1








1








I need to copy a table from one oracle schema to another, I can do this by running the following query in schema_one -



create table EMPLOYEES unrecoverable as select * from schema_two.EMPLOYEES;


which works when run using the command line or sql developer.



But the challenge is to execute this using ant script.



I have my ant target as below



<target name="create.tables">
<echo message="creating tables... " />
<sql driver="${db.driver}"
url="${db.url}"
userid="${db.username}"
password="${db.password}"
onerror="abort"
keepformat="yes"
encoding="UTF-8"
>
<transaction>
create table EMPLOYEES unrecoverable as select * from schema_two.EMPLOYEES;

</transaction>
<classpath>
<path refid="database.common.classpath"/>
</classpath>
</sql>
</target>


where db.driver,db.url,db.username and db.password are defined for schema_one.
Running this throws an error as below



I have an entry in tnsnames.ora for the schemas as well.



java.sql.SQLRecoverableException: Listener refused the connection with the following error:
ORA-12514, TNS:listener does not currently know of service requested in connect descriptor

at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:825)
at oracle.jdbc.driver.PhysicalConnection.connect(PhysicalConnection.java:751)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:38)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:593)
at org.apache.tools.ant.taskdefs.JDBCTask.getConnection(JDBCTask.java:366)
at org.apache.tools.ant.taskdefs.SQLExec.getConnection(SQLExec.java:963)
at org.apache.tools.ant.taskdefs.SQLExec.execute(SQLExec.java:628)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1405)
at org.apache.tools.ant.Project.executeTarget(Project.java:1376)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1260)
at org.apache.tools.ant.Main.runBuild(Main.java:857)
at org.apache.tools.ant.Main.startAnt(Main.java:236)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:287)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:113)
Caused by: oracle.net.ns.NetException: Listener refused the connection with the following error:
ORA-12514, TNS:listener does not currently know of service requested in connect descriptor

at oracle.net.ns.NSProtocolStream.negotiateConnection(NSProtocolStream.java:324)
at oracle.net.ns.NSProtocol.connect(NSProtocol.java:287)
at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1963)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:564)
... 22 more









share|improve this question














I need to copy a table from one oracle schema to another, I can do this by running the following query in schema_one -



create table EMPLOYEES unrecoverable as select * from schema_two.EMPLOYEES;


which works when run using the command line or sql developer.



But the challenge is to execute this using ant script.



I have my ant target as below



<target name="create.tables">
<echo message="creating tables... " />
<sql driver="${db.driver}"
url="${db.url}"
userid="${db.username}"
password="${db.password}"
onerror="abort"
keepformat="yes"
encoding="UTF-8"
>
<transaction>
create table EMPLOYEES unrecoverable as select * from schema_two.EMPLOYEES;

</transaction>
<classpath>
<path refid="database.common.classpath"/>
</classpath>
</sql>
</target>


where db.driver,db.url,db.username and db.password are defined for schema_one.
Running this throws an error as below



I have an entry in tnsnames.ora for the schemas as well.



java.sql.SQLRecoverableException: Listener refused the connection with the following error:
ORA-12514, TNS:listener does not currently know of service requested in connect descriptor

at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:825)
at oracle.jdbc.driver.PhysicalConnection.connect(PhysicalConnection.java:751)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:38)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:593)
at org.apache.tools.ant.taskdefs.JDBCTask.getConnection(JDBCTask.java:366)
at org.apache.tools.ant.taskdefs.SQLExec.getConnection(SQLExec.java:963)
at org.apache.tools.ant.taskdefs.SQLExec.execute(SQLExec.java:628)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1405)
at org.apache.tools.ant.Project.executeTarget(Project.java:1376)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1260)
at org.apache.tools.ant.Main.runBuild(Main.java:857)
at org.apache.tools.ant.Main.startAnt(Main.java:236)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:287)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:113)
Caused by: oracle.net.ns.NetException: Listener refused the connection with the following error:
ORA-12514, TNS:listener does not currently know of service requested in connect descriptor

at oracle.net.ns.NSProtocolStream.negotiateConnection(NSProtocolStream.java:324)
at oracle.net.ns.NSProtocol.connect(NSProtocol.java:287)
at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1963)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:564)
... 22 more






oracle ant






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 16 '18 at 17:37









xKirxKir

82




82













  • THen your connect string is not being constructed correctly. Are you sure all the properties being referenced are valid?

    – OldProgrammer
    Nov 16 '18 at 18:47













  • Yes they do, if I run a simple query on without schema_two reference ,it runs perfectly fine!

    – xKir
    Nov 16 '18 at 18:52











  • can you re-try using jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(HOST=myhost)(PORT=1521)(PROTOCOL=tcp))(CONNECT_DATA=(SERVICE_NAME=myorcldbservicename))) as db.url. don't forget to change myhost and myorcldbservicename.

    – guleryuz
    Nov 18 '18 at 5:43



















  • THen your connect string is not being constructed correctly. Are you sure all the properties being referenced are valid?

    – OldProgrammer
    Nov 16 '18 at 18:47













  • Yes they do, if I run a simple query on without schema_two reference ,it runs perfectly fine!

    – xKir
    Nov 16 '18 at 18:52











  • can you re-try using jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(HOST=myhost)(PORT=1521)(PROTOCOL=tcp))(CONNECT_DATA=(SERVICE_NAME=myorcldbservicename))) as db.url. don't forget to change myhost and myorcldbservicename.

    – guleryuz
    Nov 18 '18 at 5:43

















THen your connect string is not being constructed correctly. Are you sure all the properties being referenced are valid?

– OldProgrammer
Nov 16 '18 at 18:47







THen your connect string is not being constructed correctly. Are you sure all the properties being referenced are valid?

– OldProgrammer
Nov 16 '18 at 18:47















Yes they do, if I run a simple query on without schema_two reference ,it runs perfectly fine!

– xKir
Nov 16 '18 at 18:52





Yes they do, if I run a simple query on without schema_two reference ,it runs perfectly fine!

– xKir
Nov 16 '18 at 18:52













can you re-try using jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(HOST=myhost)(PORT=1521)(PROTOCOL=tcp))(CONNECT_DATA=(SERVICE_NAME=myorcldbservicename))) as db.url. don't forget to change myhost and myorcldbservicename.

– guleryuz
Nov 18 '18 at 5:43





can you re-try using jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(HOST=myhost)(PORT=1521)(PROTOCOL=tcp))(CONNECT_DATA=(SERVICE_NAME=myorcldbservicename))) as db.url. don't forget to change myhost and myorcldbservicename.

– guleryuz
Nov 18 '18 at 5:43












0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53342819%2foracle-copy-table-from-one-schema-to-another-using-ant%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53342819%2foracle-copy-table-from-one-schema-to-another-using-ant%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Florida Star v. B. J. F.

Error while running script in elastic search , gateway timeout

Adding quotations to stringified JSON object values