codehunter
codehunter

Reputation: 81

Jython : SyntaxError: Lexical error at line 29, column 32. Encountered: "$" (36), after : ""

I 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 "jdbcConn.jy"; exception information: com.ibm.bsf.BSFException: exception from Jython: Traceback (innermost last): (no code object) at line 0 File "", line 29 classpath = ["classpath" , ${ORACLE_JDBC_DRIVER_PATH}/ojdbc6.jar ] ^ SyntaxError: Lexical error at line 29, column 32. Encountered: "$" (36), after : ""

My Code :

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)

Upvotes: 0

Views: 1219

Answers (2)

Tom Barron
Tom Barron

Reputation: 1594

Your problem is in this line:

classpath = ["classpath" , ${ORACLE_JDBC_DRIVER_PATH}/ojdbc6.jar ]

Instead, do something like

opath = os.getenv("ORACLE_JDBC_DRIVER_PATH")
classpath = ["classpath", "{}/ojdbc6.jar".format(opath)]

"${ORACLE_JDBC_DRIVER_PATH}" is shell syntax, not Python.

Upvotes: 2

ham
ham

Reputation: 716

Change this line

classpath = ["classpath" , ${ORACLE_JDBC_DRIVER_PATH}/ojdbc6.jar ]

to this:

classpath = ["classpath" , "${ORACLE_JDBC_DRIVER_PATH}/ojdbc6.jar" ]

or better yet, just delete that line. Anyways, classpath is declared again later to the same value

Upvotes: 0

Related Questions