Validating ODBC DSN connections for hmvproj
search cancel

Validating ODBC DSN connections for hmvproj

book

Article ID: 262343

calendar_today

Updated On:

Products

CA Harvest Software Change Manager

Issue/Introduction

Hmvproj moves an entire Harvest project from one Harvest database schema to another Harvest database schema.  In order to connect to both the source and target databases, hmvproj uses ODBC connections.  To be successful in using hmvproj it will help to ensure the ODBC database connections for both source and target Harvest databases are configured correctly.

Environment

Release : 14.0

Resolution

If you are running hmvproj from a Windows computer for each of your Harvest databases, you should be able to test your ODBC connections by running the following Powershell script with a successful result:

$datasourcename = "*****"   <# <--- replace ***** with the name of the data source definition, be sure to enclose in double quotes       #>
$userid = "*****"           <# <--- replace ***** with the userid needed to login to the database, be sure to enclose in double quotes   #>
$password = "*****"         <# <--- replace ***** with the password needed to login to the database, be sure to enclose in double quotes #>
$conn = New-Object System.Data.Odbc.OdbcConnection("DSN=$datasourcename;UID=$userid;PWD=$password")
$conn.open()
$cmd = $conn.CreateCommand()
$cmd.CommandText = "SELECT * FROM hartableinfo"
$reader = $cmd.ExecuteReader()
$reader.Read()
Write-Output "Version Indicator " $reader[0]
Write-Output "Database ID" $reader[2]
$reader.Close()
$conn.Close()

Here is an example of how this might look:

C:\temp>powershell
Windows PowerShell
Copyright (C) 2016 Microsoft Corporation. All rights reserved.

PS C:\temp> $datasourcename = "*******"   <# <--- replace ***** with the name of the data source definition, be sure to enclose in double quotes       #>
PS C:\temp> $userid = "*******"           <# <--- replace ***** with the userid needed to login to the database, be sure to enclose in double quotes   #>
PS C:\temp> $password = "*******"         <# <--- replace ***** with the password needed to login to the database, be sure to enclose in double quotes #>
PS C:\temp> $conn = New-Object System.Data.Odbc.OdbcConnection("DSN=$datasourcename;UID=$userid;PWD=$password")
PS C:\temp> $conn.open()
PS C:\temp> $cmd = $conn.CreateCommand()
PS C:\temp> $cmd.CommandText = "SELECT * FROM hartableinfo"
PS C:\temp> $reader = $cmd.ExecuteReader()
PS C:\temp> $reader.Read()
True
PS C:\temp> Write-Output "Version Indicator " $reader[0]
Version Indicator
140000
PS C:\temp> Write-Output "Database ID" $reader[2]
Database ID
0
PS C:\temp> $reader.Close()
PS C:\temp> $conn.Close()
PS C:\temp> exit

C:\temp>

On Linux and Unix, the easiest way to test the ODBC data source definitions is with Harvest's hdbsetup utility.  Before executing, you will need to backup your existing HServer.arg file because testing datasources might make changes to this file.

You can now execute hdbsetup and use the "co" option to configure and test ODBC data source definitions for both the source and target databases.

After ODBC data sources have been tested and confirmed, don't forget to restore HServer.arg from the backup:

Additional Information

For more information on the hmvproj utilities, refer to these pages in the Harvest documentation:

Copy or Move a Project from One Database to Other

hmvproj Command-Move or Copy Projects