SqlConnect() - What format for 'server' parameter? - IBM AS400

This is a discussion on SqlConnect() - What format for 'server' parameter? - IBM AS400 ; Still looking around on the net and here for this, but when I'm calling SqlConnect() and specifying the server parameter, what does it look like? I found using WRKRDBDIRE what the name of our database is (Axxxxx), that it's type ...

+ Reply to Thread
Results 1 to 5 of 5

Thread: SqlConnect() - What format for 'server' parameter?

  1. SqlConnect() - What format for 'server' parameter?

    Still looking around on the net and here for this, but when I'm
    calling SqlConnect() and specifying the server parameter, what does it
    look like? I found using WRKRDBDIRE what the name of our database is
    (Axxxxx), that it's type and location is *LOCAL and *IP based. So, am
    I just plugging in the IP address of the server into that field, so it
    looks something like:

    SqlConnect(h_SqlDbc, "127.0.0.1", SQL_NTS, "USER", SQL_NTS,
    "PASSWORD", SQL_NTS);

    Shouldn't you need to specify the name of your database (Axxxxx) even
    if you only have one defined?

  2. Re: SqlConnect() - What format for 'server' parameter?

    Once connected, the System i is the database. If you use Operations
    Navigator and go to the Databases selection for the system you are working
    with, you will see the name of the database that has been assigned. Using
    Operations Navigator you can observe how things are laid out. Libraries are
    considered schemas. Expand Schemas and right click to add Libraries/Schemas
    to your view using the "Select Schemas to Display" options.
    HTH,
    D.J.
    "Mr. K.V.B.L." wrote in message
    news:8a139efb-c8bf-4ebd-926c-daccb076af0c@d45g2000hsc.googlegroups.com...
    > Still looking around on the net and here for this, but when I'm
    > calling SqlConnect() and specifying the server parameter, what does it
    > look like? I found using WRKRDBDIRE what the name of our database is
    > (Axxxxx), that it's type and location is *LOCAL and *IP based. So, am
    > I just plugging in the IP address of the server into that field, so it
    > looks something like:
    >
    > SqlConnect(h_SqlDbc, "127.0.0.1", SQL_NTS, "USER", SQL_NTS,
    > "PASSWORD", SQL_NTS);
    >
    > Shouldn't you need to specify the name of your database (Axxxxx) even
    > if you only have one defined?




  3. Re: SqlConnect() - What format for 'server' parameter?

    On Jul 9, 11:31*am, "Dick J" wrote:
    > Once connected, the System i is the database.


    Don't IASPs change the picture somewhat?

  4. Re: SqlConnect() - What format for 'server' parameter?

    On Jul 9, 5:31*am, "Dick J" wrote:
    > Once connected, the System i is the database. *If you use Operations
    > Navigator and go to the Databases selection for the system you are working
    > with, you will see the name of the database that has been assigned. *Using
    > Operations Navigator you can observe how things are laid out. Libraries are
    > considered schemas. *Expand Schemas and right click to add Libraries/Schemas
    > to your view using the "Select Schemas to Display" options.
    > HTH,
    > D.J."Mr. K.V.B.L." wrote in message
    >


    MMMmmmmm... Ok, that doesn't answer my question. I can't find any
    good documentation that spells out what the 'server' parameter of
    SqlConnect() is supposed to be. After some playing around I found
    that just using "A10289AF", the name of our database, works, but what
    if you're connecting to a database over the net?

    > news:8a139efb-c8bf-4ebd-926c-daccb076af0c@d45g2000hsc.googlegroups.com...
    >
    > > Still looking around on the net and here for this, but when I'm
    > > calling SqlConnect() and specifying the server parameter, what does it
    > > look like? *I found using WRKRDBDIRE what the name of our database is
    > > (Axxxxx), that it's type and location is *LOCAL and *IP based. *So, am
    > > I just plugging in the IP address of the server into that field, so it
    > > looks something like:

    >
    > > SqlConnect(h_SqlDbc, "127.0.0.1", SQL_NTS, "USER", SQL_NTS,
    > > "PASSWORD", SQL_NTS);

    >
    > > Shouldn't you need to specify the name of your database (Axxxxx) even
    > > if you only have one defined?



  5. Re: SqlConnect() - What format for 'server' parameter?

    Mr. K.V.B.L. wrote:
    > Still looking around on the net and here for this, but when I'm
    > calling SqlConnect() and specifying the server parameter, what does
    > it look like? I found using WRKRDBDIRE what the name of our database
    > is (Axxxxx), that its type and location is *LOCAL and *IP based. So,
    > am I just plugging in the IP address of the server into that field,
    > so it looks something like:
    >
    > SqlConnect(h_SqlDbc, "127.0.0.1", SQL_NTS,
    > "USER", SQL_NTS, "PASSWORD", SQL_NTS);
    >
    > Shouldn't you need to specify the name of your database (Axxxxx)
    > even if you only have one defined?


    Not if the application runs local to the server, and intends to [be]
    run in what partition and iASP in which it resides. In that case when
    the application is [created or restored to] the server where it will
    run, then the application can run connected to the *LOCAL database when
    no database is named. If the database name is specified, then that
    application created or restored to a different server [LPAR or iASP],
    would try to connect to the named server. The value as NULL or empty
    string should default to a *LOCAL connect; i.e. similar to an
    interactive STRSQL implicit local connection.
    http://publib.boulder.ibm.com/infoce...adpexusing.htm
    "rtnc=SQLConnect(hdbc,NULL,0,NULL,0,NULL,0);"

    http://publib.boulder.ibm.com/infoce...rzadphdapi.htm
    "SQLConnect - Connect to a data source"
    http://publib.boulder.ibm.com/infoce...zadpfnconn.htm
    "SQLConnect() establishes a connection to the target database. The
    application can _optionally supply_ _a target SQL database_, an
    authorization name, and an authentication string."
    http://publib.boulder.ibm.com/infoce...zadpfnconn.htm
    "If the application does not supply a target database (szDSN), the CLI
    uses the _local_ database as the default."

    http://publib.boulder.ibm.com/infoce...strictions.htm
    "Restrictions ... CLI server mode" "Because DataSources is used to find
    the name of the RDB for connection, IBM supports passing a NULL pointer
    for the RDB name on SQLConnect to obtain a local connection. This makes
    it possible to write a generic program, when there is no prior knowledge
    of the system names."

    http://publib.boulder.ibm.com/infoce...mbeddedsql.htm
    "example shows embedded statements in comments and the equivalent DB2
    UDB call level interface (CLI) function calls."

    /* EXEC SQL CONNECT TO :server
    USER :uid USING :authentication_string; */
    SQLAllocEnv (&henv); /* allocate an environment handle */
    SQLAllocConnect (henv, &hdbc); /* allocate a connection handle */
    /* Connect to database indicated by "server" variable with */
    /* authorization-name given in "uid", authentication-string given*/
    /* in "pwd". Note server, uid, and pwd contain null-terminated */
    /* strings, as indicated by the 3 input lengths set to SQL_NTS */
    if (SQLConnect (hdbc, server, SQL_NTS, NULL, SQL_NTS, NULL, SQL_NTS)
    != SQL_SUCCESS)

    Regards, Chuck

+ Reply to Thread