我的代码中出现语法错误。任何人都可以说语法中的错误是什么?我是这种语言的新手,没有太多想法。
错误讯息:
我的代码:
import sys
## **JDBCProvider** ##
def OracleJDBC(cellName,serverName):
name ="Oracle JDBC Driver"
print " Name of JDBC Provider which will be created ---> " + name
print " ----------------------------------------------------------------------------------------- "
# Gets the name of cell
cell = AdminControl.getCell()
print cell
cellid = AdminConfig.getid('/Cell:'+ cell +'/')
print cellid
print " ----------------------------------------------------------------------------------------- "
## Creating New JDBC Provider ##
print " Creating New JDBC Provider :"+ name
n1 = ["name" , "Oracle JDBC Driver" ]
desc = ["description" , "Oracle JDBC Driver"]
impn = ["implementationClassName" ,
"oracle.jdbc.pool.OracleConnectionPoolDataSource"]
classpath = ["classpath" , ${ORACLE_JDBC_DRIVER_PATH}/ojdbc6.jar ]
attrs1 = [n1 , impn , desc , classpath]
n1 = ["name" , "Oracle JDBC Driver" ]
desc = ["description" , "Oracle JDBC Driver"]
impn = ["implementationClassName" , "oracle.jdbc.pool.OracleConnectionPoolDataSource"]
classpath = ["classpath" , "${ORACLE_JDBC_DRIVER_PATH}/ojdbc6.jar"]
attrs1 = [n1 , impn , desc , classpath]
Serverid = AdminConfig.getid("/Cell:" + cellName + "/ServerName:" + serverName +"/")
jdbc = AdminConfig.create('JDBCProvider', Serverid, attrs1)
print " New JDBC Provider created :" + name
AdminConfig.save()
print " Saving Configuraion "
print " ----------------------------------------------------------------------------------------- "
####################################################################################################################
####################################################################################################################
#main program starts here
if __name__ == '__main__':
cellName = sys.argv[0]
serverName = sys.argv[1]
OracleJDBC(cellName,serverName)
答案 0 :(得分:2)
你的问题在这一行:
classpath = ["classpath" , ${ORACLE_JDBC_DRIVER_PATH}/ojdbc6.jar ]
相反,做一些像
这样的事情opath = os.getenv("ORACLE_JDBC_DRIVER_PATH")
classpath = ["classpath", "{}/ojdbc6.jar".format(opath)]
" $ {ORACLE_JDBC_DRIVER_PATH}"是shell语法,而不是Python。
答案 1 :(得分:0)
更改此行
classpath = ["classpath" , ${ORACLE_JDBC_DRIVER_PATH}/ojdbc6.jar ]
到此:
classpath = ["classpath" , "${ORACLE_JDBC_DRIVER_PATH}/ojdbc6.jar" ]
或更好,只需删除该行。无论如何,classpath稍后再次声明为相同的值