Yes you can.
I have written code that generates the appropriate script and then invokes it.
Basically you have to write script and invoke it from a command prompt as:
db2cmd <fullpathtoyourbatchfile>\NameoofFile.bat
There is some documentation in db2 connect that details all the "pieces" of the DSN info such as node, ip address etc.
In the sample script below, this could be placed in a text file with a .bat extension.
YOURDSNNAME would be the name of the dsn you are trying to create
YOURDBNAME would be the name of your database on the server
YOURIPADDRESS would be the ip address of your db2 server as setup (not sure which platform you are going to, we are going to a IBM mainframe)
YOURIPPORT would be the ip port setup for your server.
Hope this helps, let me know if you have further questions.
DB2 UPDATE DBM CFG USING CATALOG_NOAUTH YES
DB2 TERMINATE
DB2 DB2STOP
DB2 DB2START
@ECHO * CREATING YOURDSNNAME YOURDBNAME ODBC SYSTEM DATA SOURCE
DB2 UNCATALOG NODE TCP0000
DB2 UNCATALOG SYSTEM ODBC DATA SOURCE YOURDSNNAME
DB2 UNCATALOG DCS DATABASE YOURDBNAME
DB2 UNCATALOG DCS DATABASE YOURDSNNAME
DB2 UNCATALOG DB YOURDSNNAME
DB2 UNCATALOG NODE YOURDBNAME
DB2 UNCATALOG NODE YOURDSNNAME
DB2 TERMINATE
DB2 DB2STOP
DB2 DB2START
DB2 CATALOG TCPIP NODE YOURDBNAME REMOTE YOURIPADDRESS SERVER YOURIPPORT OSTYPE MVS
DB2 CATALOG DB YOURDBNAME AS YOURDSNNAME AT NODE YOURDBNAME AUTHENTICATION DCS
DB2 CATALOG DCS DATABASE YOURDBNAME AS YOURDBNAME
DB2 CATALOG SYSTEM ODBC DATA SOURCE YOURDSNNAME
DB2 UPDATE DBM CFG USING RQRIOBLK 32767
DB2 TERMINATE
DB2 DB2STOP
DB2 DB2START
EXIT
Thanks alot for the reply...could you explain what some of this means?? It works some of the time, but why use DCS authenication?? Also, what is the RQRIOBLK dbm cfg parameter?? I really appreciate your help...just need some clarification.
This particular example I gave connects to an IBM mainframe running DB2 on the server (mainframe).
DCS authentication means that the security will get authenticated on the mainframe. In my case, authentication is done by RACF (security for mainframe). Look at this link here for a little more explanation.
As to what it means, IBM DB2 connect works kind of strange it requires a NODE, DATABASE and DCS. It creates all this data in a structure on the client.
It works all the time for me, what platform are you going to?
Also, dont forget to substitute the correct values for YOURDSNNAME, YOURDBNAME, YOURIPADDRESS and YOURIPPORT.
These MUST be correct or it wont work.
Also, try using the client configuration assistant to build the DSN if you are having trouble. This will validate that your parameters (ip address, port etc.) are correct. The example I gave was in response to "how to generate a datasource using script"
P.S. Make sure you "register it for ODBC" (there is a checkbox in there), otherwise your programs wont be able to connect to it using ODBC/ADO.
Hope this helps.
Gilbert M. Vanegas
Programmer Analyst III
County of San Bernardino - ISD
Email : gvanegas@isd.sbcounty.gov
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.