语法错误Jython

时间:2016-10-19 05:17:11

标签: python jython

我的代码中出现语法错误。任何人都可以说语法有什么问题吗?我是这种语言的新手,没有太多想法。

错误消息

  

WASX7017E:运行文件“JDBCoracle.py”时收到异常;异常信息:com.ibm.bsf.BSFException:来自Jython的异常:Traceback(最里面的最后一个):(第0行没有代码对象)文件“”,第8行name =“Oracle JDBC Driver”^ SyntaxError:语法无效

我的代码:

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]

   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

   OracleJDBC(cellName,serverName)

有人可以帮助我看看我做错了什么吗?我是这种语言的新手。

1 个答案:

答案 0 :(得分:1)

您的错误是def OracleJDBC(cellName,serverName,):中的逗号;消除它,事情会奏效。

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" , '/path/to/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__':
    OracleJDBC(cellName,serverName)