简体   繁体   English

Jython:SyntaxError:语法无效

[英]Jython : SyntaxError: invalid syntax

am getting a syntax error in my code. 我的代码中出现语法错误。 Can anyone say what's wrong in the syntax? 谁能说出语法错误吗? I am new to this language, don't have much of an idea. 我是这种语言的新手,没有太多想法。

Error Message: 错误信息:

WASX7017E: Exception received while running file "jdbcconnection.jy"; WASX7017E:运行文件“ jdbcconnection.jy”时收到异常; exception information: com.ibm.bsf.BSFException: exception from Jython: Traceback (innermost last): (no code object) at line 0 File "", line 13 AdminTask.createJDBCProvider('[-scope Node='+nodeName+',Server='+serverName' -databaseType Oracle -providerType "Oracle JDBC Driver" -implementationType "Connection pool data source" - name "Oracle JDBC Driver" -description "Oracle JDBC Driver" -classpath [${ORACLE_JDBC_DRIVER_PATH}/ojdbc6.jar] -nativePath "" ]') ^ SyntaxError: invalid syntax 异常信息:com.ibm.bsf.BSFException:来自Jython的异常:Traceback(最里面的最后一个):(无代码对象)位于第0行文件“”,第13行AdminTask.createJDBCProvider('[-scope Node ='+ nodeName +', Server ='+ serverName'-databaseType Oracle -providerType“ Oracle JDBC驱动程序” -implementationType“连接池数据源”-名称“ Oracle JDBC驱动程序”-说明“ Oracle JDBC驱动程序” -classpath [$ {ORACLE_JDBC_DRIVER_PATH} /ojdbc6.jar] -nativePath“”]')^ SyntaxError:语法无效


My code: 我的代码:

import sys

def jdbcoracle(nodeName,serverName):
        print 'Create JDBC provider'
    AdminTask.createJDBCProvider('[-scope Node='+nodeName+',Server='+serverName' -databaseType Oracle -providerType "Oracle JDBC Driver" -implementationType "Connection pool data source" -name "Oracle JDBC Driver" -description "Oracle JDBC Driver" -classpath [${ORACLE_JDBC_DRIVER_PATH}/ojdbc6.jar] -nativePath "" ]')
    AdminTask.createJDBCProvider('[-scope Node='+nodeName+',Server='+serverName' -databaseType Oracle -providerType "Oracle JDBC Driver" -implementationType "XA data source" -name "Oracle JDBC Driver (XA)" -description "Oracle JDBC Driver (XA)" -classpath [${ORACLE_JDBC_DRIVER_PATH}/ojdbc6.jar] -nativePath "" ]')
        AdminConfig.save()  
    print 'JDBC provider created'   
#-------------------------------------
# Main Application starts from here
#-------------------------------------
global nodeName, cellName
nodeName = sys.argv[0]
serverName = sys.argv[1]
jdbcoracle(nodeName,serverName)

Your syntax would be invalid in any language. 您的语法在任何语言中均无效。 You have '...Server='+serverName' ...' - you are missing a + before the reopening of the quote. 您有'...Server='+serverName' ...'重新打开引号之前缺少+

Of course, you should not be building up strings like that; 当然,您不应该建立这样的字符串。 you should be using one of the many string formatting features available in Python, for example: 您应该使用Python中提供的许多字符串格式化功能之一,例如:

'[-scope Node={},Server={} -databaseType...'.format(nodeName, serverName)

I suspect you also mean ORACLE_JDBC_DRIVER_PATH to be an interpolated variable, but only you know where that is supposed to be coming from. 我怀疑您还意味着ORACLE_JDBC_DRIVER_PATH是一个插值变量,但只有您知道该从何而来。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM