因为我是antscript和sql / oracle的新手因此我无法理解我所拥有的日志。所以请你通过查看我应该移动的方向来告诉我。这是连接吗?设置或其他问题。 用于运行ant脚本的Build.xml定义如下
<?xml version="1.0"?>
<project name="Hello World Project" default="myTarget">
<target name="myTarget">
<!-- directory where db scritps reside -->
<property name="oracle.scriptPath" value="D:\\ganganshu" />
<!-- path of tnsnames.org file -->
<property name="oracle.tns_alias" value="wind" />
<!-- Oracle user name -->
<property name="oracle.user_name" value="system" />
<!-- Oracle Password -->
<property name="oracle.password" value="manager" />
<!-- login.sql should have sqlcode exit so failonerror will fail build -->
<exec executable="sqlplus" failonerror="true">
<arg value="${oracle.user_name}/${oracle.password}@${tns_alias}"/>
<arg value="@${oracle.scriptPath}\\SILO1_schema_script.sql"/>
</exec>
</target>
</project>
and my sql script file is defined below
DROP TABLESPACE SILO2 INCLUDING CONTENTS CASCADE CONSTRAINTS;
DROP USER SILO2;
CREATE TABLESPACE SILO2 DATAFILE 'D:\PTC\WINDCHILL_10.2\OCU\ORADATA\WIND\SILO2.DBF' SIZE 8388608 AUTOEXTEND ON NEXT 131072 MAXSIZE 32767M LOGGING ONLINE PERMANENT BLOCKSIZE 8192 EXTENT MANAGEMENT LOCAL AUTOALLOCATE DEFAULT NOCOMPRESS SEGMENT SPACE MANAGEMENT AUTO;
/* USER SQL */
CREATE USER SILO2 IDENTIFIED BY SILO2 DEFAULT TABLESPACE "SILO2" TEMPORARY TABLESPACE "TEMP";
but when i try to run the ant file I am getting this in the command prompt and the
scheama is not getting created
[exec]
[exec] SQL*Plus: Release 11.2.0.1.0 Production on Mon Dec 16 11:00:32 2013
[exec]
[exec] Copyright (c) 1982, 2010, Oracle. All rights reserved.
[exec]
[exec] ERROR:
[exec] ORA-12541: TNS:no listener
[exec]
[exec]
[exec] Enter user-name:
和我的tnsnames.ora包含此
# TNSNAMES.ORA Network Configuration File: D:\temp\OSA92\network\admin\tnsnames.ora
# Generated by Oracle configuration tools.
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)
wind =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = renault-dev.ptcnet.ptc.com)(PORT = 1521))
)
(CONNECT_DATA =
(SID = wind)
)
)
and I have set tns_alias as a property in build.xml only and not anywhere else
答案 0 :(得分:1)
您将脚本名称作为参数传递,但您没有使用@
符号to tell SQL*Plus to run the script:
<arg value="@${oracle.scriptPath}\\SILO1_schema_script.sql"/>
正如@GregHNZ在评论中指出的那样,你似乎没有设置tnsalias
。这些中的任何一个都会生成您正在看到的SQL * Plus用法消息。您的命令行最终为:
sqlplus system/manager@ D:\ganganshu\SILO1_schema_script.sql
而不是:
sqlplus system/manager@alias @D:\ganganshu\SILO1_schema_script.sql
您的oracle.tnsnames
财产也没有做任何事情。运行SQL * Plus的环境需要将TNS_ADMIN
设置为D:\\ptc\\Windchill_10.2\ocu\Conf
才能使用该目录中的tnsnames.ora
文件。您无法在命令行上传递它。
根据您的更新显示tnsnames.ora
文件的内容,您的tns_alias
媒体资源应为:
<property name="oracle.tns_alias" value="wind" />
这会让你成为命令行:
sqlplus system/manager@wind @D:\ganganshu\SILO1_schema_script.sql
...您可以从Windows命令提示符进行测试。