JDBC using NetRexx

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

JDBC using NetRexx

Casale, Vincent

I trying to use JDBC from an NT workstation to connect up to the mainframe.
In my code below I get the following error:

 39 +++     jdbcCon = Connection DriverManager.getConnection (url, userid,
passw
ord)
    +++                                        ^^^^^^^^^^^^^
    +++ Error: The property 'getConnection' cannot be found in class
'java.sql.D
riverManager' or a superclass
Compilation of 'jdbcmd.nrx' failed [one error]


with this line of code.....

/**/
   
   import java.sql.

   /* register the DB2 for OS/390 driver with DriverManager */
    do
      Class.forName('COM.ibm.db2.jdbc.app.DB2Driver').newInstance()
   
      catch e1 = Exception
       say'The DB2 Driver class could not be found and loaded.'
       say 'Exception ('e1') caught: \n' e1.getMessage()
       exit 1
    end

    say "**** JDBC Entry within class JDBCMD."

    url = "jdbc:db2:zd60db2"
    userid = 'xxxxxxxx'
    password = 'xxxxxxxx'  
       
    jdbcCon = Connection DriverManager.getConnection (url, userid, password)
    say "**** JDBC Connection to DB2 for OS/390."

    /* Create the Statement */
    Statement stmt = jdbcCon.createStatement()
    say "**** JDBC Statement Created"

    /* Execute a Query from table */
    ResultSet rs = stmt.executeQuery("SELECT vend_nm from yr2000t.vend")
    say "**** JDBC Result Set Created"

    /* Print all of the table names to sysout */
    say "From Vendor Table"
    loop while (rs.next())
      String s = rs.getString(1)
      say "Vendor Name = " + s
    end
    say "**** JDBC Result Set output completed"

    /* Close the statement */
    stmt.close();
    say "**** JDBC Statement Closed"

    /* Close the connection */
    jdbcCon.close();
    say "**** JDBC Disconnect from DB2 for OS/390."

    catch( Exception e )
      e.printStackTrace();
 
    say "**** JDBC Processing Complete ****"

Thanks,

Vincent Casale
S390 Web Engineering Group, Mgr.
201-524-2034
[hidden email]

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe from this mailing list ( ibm-netrexx ), please send a note to
[hidden email]
with the following message in the body of the note
unsubscribe ibm-netrexx <e-mail address>

Reply | Threaded
Open this post in threaded view
|

Re: JDBC using NetRexx

dIon Gillard/Multitask Consulting/AU
Remove the space between getConnection and the '('

--
dIon Gillard, Multitask Consulting
Work:      http://www.multitask.com.au
Play:        http://www.trongus.com



I trying to use JDBC from an NT workstation to connect up to the
mainframe.
In my code below I get the following error:

 39 +++     jdbcCon = Connection DriverManager.getConnection (url, userid,
passw
ord)
    +++                                        ^^^^^^^^^^^^^
    +++ Error: The property 'getConnection' cannot be found in class
'java.sql.D
riverManager' or a superclass
Compilation of 'jdbcmd.nrx' failed [one error]


with this line of code.....

/**/
 
   import java.sql.

   /* register the DB2 for OS/390 driver with DriverManager */
    do
      Class.forName('COM.ibm.db2.jdbc.app.DB2Driver').newInstance()
 
      catch e1 = Exception
       say'The DB2 Driver class could not be found and loaded.'
       say 'Exception ('e1') caught: \n' e1.getMessage()
       exit 1
    end

    say "**** JDBC Entry within class JDBCMD."

    url = "jdbc:db2:zd60db2"
    userid = 'xxxxxxxx'
    password = 'xxxxxxxx'
 
    jdbcCon = Connection DriverManager.getConnection (url, userid,
password)
    say "**** JDBC Connection to DB2 for OS/390."

    /* Create the Statement */
    Statement stmt = jdbcCon.createStatement()
    say "**** JDBC Statement Created"

    /* Execute a Query from table */
    ResultSet rs = stmt.executeQuery("SELECT vend_nm from yr2000t.vend")
    say "**** JDBC Result Set Created"

    /* Print all of the table names to sysout */
    say "From Vendor Table"
    loop while (rs.next())
      String s = rs.getString(1)
      say "Vendor Name = " + s
    end
    say "**** JDBC Result Set output completed"

    /* Close the statement */
    stmt.close();
    say "**** JDBC Statement Closed"

    /* Close the connection */
    jdbcCon.close();
    say "**** JDBC Disconnect from DB2 for OS/390."

    catch( Exception e )
      e.printStackTrace();
 
    say "**** JDBC Processing Complete ****"

Thanks,

Vincent Casale
S390 Web Engineering Group, Mgr.
201-524-2034
[hidden email]

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe from this mailing list ( ibm-netrexx ), please send a note
to
[hidden email]
with the following message in the body of the note
unsubscribe ibm-netrexx <e-mail address>



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe from this mailing list ( ibm-netrexx ), please send a note to
[hidden email]
with the following message in the body of the note
unsubscribe ibm-netrexx <e-mail address>