Skip to main content

alphaWorks  >  Forums  >  Starter Toolkit for DB2 on Rails  >  developerWorks

Rails to DB2 z/OS Does db:migrate have to use DSNDB04    Point your RSS reader here for a feed of the latest messages in this thread


     

 
 

My developerWorks
 Welcome, Guest
Sign in or register
Permlink Replies: 8 - Pages: 1 - Last Post: Jun 6, 2008 7:14 AM Last Post By: mariosavio Threads: [ Previous | Next ]
jlueke

Posts: 5
Registered: Jun 03, 2008 11:32:28 AM
Rails to DB2 z/OS Does db:migrate have to use DSNDB04
Posted: Jun 03, 2008 11:34:11 AM
Click to report abuse...   Click to reply to this thread Reply
Is there a way to specify a z/os database/tablespace template to be used for rails migrations? The database keyword is needed for connection to the subsystem so the created objects end up in DSNDB04 which is usable but not ideal.
Praveen Devarao

Posts: 4
Registered: May 28, 2008 12:29:34 AM
Re: Rails to DB2 z/OS Does db:migrate have to use DSNDB04
Posted: Jun 03, 2008 01:14:46 PM   in response to: jlueke in response to: jlueke's post
Click to report abuse...   Click to reply to this thread Reply
Hi jlueke,

Yes, you can specify a zOS database that you want to use in the rails application. Add the following in the database.yml file along with the relevant values.

:adapter => 'ibm_db',
:username => 'db2user',
:password => 'secret',
:host => '<host name (ip address will also do)>',#(optional if database is cataloged)
:port => '<port number>',#(optional if database is cataloged)
:schema => '<schema name>',# (optional)
:account => 'tester', #(optional)
:app_user => 'tester_11',# (optional)
:application => 'rails_tests',# (optional)
:workstation => 'auckland', #(optional)
:database => '<database name>'

This will allow you to have connected to the database,that you want, on zOS.

Thank you
jlueke

Posts: 5
Registered: Jun 03, 2008 11:32:28 AM
Re: Rails to DB2 z/OS Does db:migrate have to use DSNDB04
Posted: Jun 03, 2008 02:03:16 PM   in response to: Praveen Devarao in response to: Praveen Devarao's post
Click to report abuse...   Click to reply to this thread Reply
Which of those keywords will control the logical database, that is the substitute for DSNDB04? In my database.yml the database: keyword is the name of the cataloged ODBC datasource. Do I have to connect directly to the host to use the database keyword for the logical meaning on z/os?
mariosavio

Posts: 6
Registered: Oct 29, 2007 06:24:37 AM
Re: Rails to DB2 z/OS Does db:migrate have to use DSNDB04
Posted: Jun 04, 2008 07:09:58 AM   in response to: jlueke in response to: jlueke's post
Click to report abuse...   Click to reply to this thread Reply
Hi jlueke,

The ':database' parameter is the one. However you have mentioned that your database name is a not a DB2 client catalogued database, but a ODBC DSN. Can you catalog the z/OS DB on your DB2 client and then use the catalogued name in ':database'. Here is an example

db2 catalog tcpip node <ALIAS_FOR_NODENAME> remote <z/OS IP Address> server 448 ostype mvs

db2 catalog dcs database <ALIAS_FOR DBNAME> as <THE_ACTUAL_DBNAME_ON_Z>

db2 catalog database <SAME_DBNAME_ALIAS_AS_ABOVE> as <SAME_DBNAME_ALIAS_AS_ABOVE> at node <SAME_NODENAME_ALIAS_AS_ABOVE>

Now in your database.yml use <ALIAS_FOR_DBNAME>

thanks
Mario

Mario Briggs
IBM OpenSource Application Development Team
India Software Labs, Bangalore (India)
jlueke

Posts: 5
Registered: Jun 03, 2008 11:32:28 AM
Re: Rails to DB2 z/OS Does db:migrate have to use DSNDB04
Posted: Jun 04, 2008 10:44:26 AM   in response to: mariosavio in response to: mariosavio's post
Click to report abuse...   Click to reply to this thread Reply
Hi Mario,

As I understand it the DCS entry is for subsystems that are part of a datasharing group but now for created databases on z. When I do what you describe I get

Failed to connect to the mytest due to: IBMCLI Driver SQL30061N The database alias or database name "AJOD001 " was not found at the remote node. SQLSTATE=08004
SQLCODE=-30061

My dev database on Z is AJOD001. I don't know if maybe the traling spaces in the error are indicative of an issue?
mariosavio

Posts: 6
Registered: Oct 29, 2007 06:24:37 AM
Re: Rails to DB2 z/OS Does db:migrate have to use DSNDB04
Posted: Jun 04, 2008 12:41:46 PM   in response to: jlueke in response to: jlueke's post
Click to report abuse...   Click to reply to this thread Reply
Hi jleuke,

Ignore the space in the error message. As is evident by now, once you have the database catalogued correctly on the client and are able to connect to it using the DB2 CLP, your rails app too will connect to the z DB

You need the right catalog commands given your environment. How are you connecting to z from your LUW client?

You can use the DB2CA to catalog your connection correctly - http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp?topic=/com.ibm.db2.udb.doc/doc/c0008237.htm

thanks
Mario

Message was edited by: mariosavio
jlueke

Posts: 5
Registered: Jun 03, 2008 11:32:28 AM
Re: Rails to DB2 z/OS Does db:migrate have to use DSNDB04
Posted: Jun 04, 2008 02:09:21 PM   in response to: mariosavio in response to: mariosavio's post
Click to report abuse...   Click to reply to this thread Reply
I have a tcpip node that points to the mainframe and port for the db2 subsystem
I then cataloged a dcs entry mytest as ajod001 and that doesn't work. If I catalog the dcs entry for the DB2 mainframe subsystem then I can connect

This works

Local database name = MYTEST3
Target database name = DB2T <--- subsystem name
Application requestor name =
DCS parameters =
Comment =
DCS directory release level = 0x0100

This doesn't

Local database name = MYTEST
Target database name = AJOD001 <--- my mainframe personal database
Application requestor name =
DCS parameters =
Comment =
DCS directory release level = 0x0100

Of course when I connect to mytest3 and build a table it is created in DSNDB04

mariosavio

Posts: 6
Registered: Oct 29, 2007 06:24:37 AM
Re: Rails to DB2 z/OS Does db:migrate have to use DSNDB04
Posted: Jun 05, 2008 02:52:30 AM   in response to: jlueke in response to: jlueke's post
Click to report abuse...   Click to reply to this thread Reply
Hi jlueke,

You are right. Even in my case i was connecting to the instance and the tables were getting created in DSNDB04. I was confused between the instance and the database. I will ping my sources and get back to you on this.


thanks
Mario

Message was edited by: mariosavio
mariosavio

Posts: 6
Registered: Oct 29, 2007 06:24:37 AM
Re: Rails to DB2 z/OS Does db:migrate have to use DSNDB04
Posted: Jun 06, 2008 07:14:11 AM   in response to: jlueke in response to: jlueke's post
Click to report abuse...   Click to reply to this thread Reply
Hi jleuke,

It is not possible to connect to a specific database on DB2 z/OS (because each database does not have its own catalog). You have to connect to the subsystem only (which has the catalog for the entire subsystem).

So the suggested approach of trying to connect to the specific db is not possible. We can consider supporting the "IN DBNAME.TBLSPACE" for z/OS when generating the 'create table' DDL from Rails in future. But for now, that looks like it is not possible.

thanks
Mario

Mario Briggs
IBM OpenSource Application Development Team
India Software Labs, Bangalore (India)

Point your RSS reader here for a feed of the latest messages in all forums