How to install MTS on virtual Windows 2008 server ?

0

Category:

How to install the MTS on virtual Windows 2008 ?


If you have corrupted MTS installation and you want to clean up , please follow the below given steps.

1. Unconfigure the docbase using MTS configuration program. 
2. Uninstall MTS 
3. Remove the remaining Documentum products from Add/Remove Programs. 
4. Delete the following folders and all contents: 
C:\Documentum 
C:\Program Files\Documentum 
5. Delete the Documentum entries from registry. 
6. Reboot the MTS machine to make sure everything is clean. 
7. Back up your custom profiles 
8. Log in to DA as an admin user. 
9. Delete the Media Server folder, located in: \System (select all children and all versions when prompted during delete) 
10. Navigate to \System\Applications 
11. Delete the CTSTransformRequest, MediaProfile, and Transformation folders if present 
(including all versions and sub folders). 
12. Navigate to the System\Modules\TBO folder 
13. Delete all of the following folders (if present): 
• dm_cts_response 
• dm_media_profile 
• dm_transform_request 
• dmc_cts_reporting_config 
• dmc_cts_request_archiving 
14. Navigate to the System\Modules\SBO folder and: 
• Delete all of the folders that start with "com.documentum.services.cts..."; 
• Delete all of the folders that start with "com.documentum.services.dam...". 
15. Run the following two DQL statements against the docbase, in this order: 
DQL> delete cts_instance_info object 
DQL> drop type cts_instance_info 
Restart the docbase

Install the MTS fresh after following the above given steps


1 Install MTS 6.5 SP3,
2- install 2 DAR files, 
3 configure MTS against this docbase again to see
4- Check the logs if everything has started properly 




Happy installing.



How to connect with Oracle DB using Java ?

0

Category:

Here is the code for connecting with Oracle DB using java .

please download the odbc14.jar file from the following link(http://www.java2s.com/Code/Jar/o/Downloadojdbc14jar.htm) and add it to the class path or add it to Eclipse as external jar .

If you use Eclipse like me , follow the below given step.
Go to Project->Right Click ->Properties->Java Build-> library tab-> external lib-> select obdc14.jar and this code is going to work .



import java.sql.*;
public class MainDriver {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub

Connection connection = null;
try {
   // Load the JDBC driver
   String driverName = "oracle.jdbc.driver.OracleDriver";
   Class.forName(driverName);

   // Create a connection to the database
   String serverName = "10.24.148.240";
   String portNumber = "1777";
   String sid = "DOCDEV";
   String url = "jdbc:oracle:thin:@" + serverName + ":" + portNumber + ":" + sid;
   String username = "SAECMS";
   String password = "Amtrak_2011De";
   connection = DriverManager.getConnection(url, username, password);
   if(connection!= null)
    System.out.println("Connected Succussfully");
   System.out.println("Byue bye");
 
  // System.in.read();
} catch (ClassNotFoundException e) {
   // Could not find the database driver
System.out.println(""+e.getMessage());
} catch (SQLException e) {
   // Could not connect to the database
System.out.println(e.getMessage());
}

}

}


Happy Coding.



Unix Based Admin Commands Cheat Sheet

0

Category:

Unix some Admin commands
File system
  • cat
  • cd
  • chmod
  • chown
  • chgrp
  • cksum
  • cmp
  • cp
  • dd
  • du
  • df
  • file
  • fsck
  • fuser
  • ln
  • ls
  • lsattr
  • lsof
  • mkdir
  • mount
  • mv
  • pax
  • pwd
  • rm
  • rmdir
  • size
  • split
  • tee
  • touch
  • type
  • umask

Processes
  • at
  • bg
  • chroot
  • cron
  • kill
  • killall
  • nice
  • pgrep
  • pidof
  • pkill
  • ps
  • pstree
  • time
  • top


User environment
  • clear
  • env
  • exit
  • finger
  • history
  • id
  • logname
  • mesg
  • passwd
  • su
  • sudo
  • uptime
  • talk
  • tput
  • uname
  • w
  • wall
  • who
  • whoami
  • write

Text processing
  • awk
  • banner
  • basename
  • comm
  • csplit
  • cut
  • dirname
  • ed
  • ex
  • fmt
  • head
  • iconv
  • join
  • less
  • more
  • paste
  • sed
  • sort
  • spell
  • strings
  • tail
  • tr
  • uniq
  • vi
  • wc
  • xargs

Shell Utilities
  • alias
  • echo
  • expr
  • printf
  • sleep
  • test
  • true and false
  • unset
  • wait
  • yes

Networking
  • dig
  • inetd
  • host
  • ifconfig
  • netstat
  • nslookup
  • ping
  • rdate
  • rlogin
  • netcat
  • ssh
  • traceroute

Searching
  • find
  • grep
  • locate
  • whatis
  • whereis
  • which

Documentation
  • apropos
  • help
  • info
  • man

Miscellaneous
  • bc
  • cal
  • date
  • lp
  • lpr

Happy scripting

How to change Apache Tomcat port XXXX(9080)

0

Category:

How to change the Port on TOMCAT to XXXX(9080).


In the server.xml file; locate the following segment.
Connector port="8080"
By changing this 8080 value of port attribute, server would start listening on new port number.
Connector port="9080"
Save the changed server.xml file and start the Tomcat server


How to execute an SQL script file in SQLPlus?

0

Category: ,

How to execute an SQL script file in SQLPlus?


To execute a script file in SQLPlus, type @ and then the file name.

SQL > @[file]

if your file was called XXX.sql, you'd type the following command at the SQL prompt:

SQL > @script.sql

The above command assumes that the file is in the current directory. (ie: the current directory is usually the directory that you were located in before you launched SQLPlus.)Check the current directory using pw command on linux based systems.

If you need to execute a script file that is not in the current directory, you would type:

SQL > @[path][file]

Example:

SQL > @/oracle/temp/XXX.sql

This command would run a script file called script.sql that was located in the /oracle/temp directory.

Applicaton Xtender to Documentum Migration.

7

Category: , ,

Application Xtender to Documentum Migration

Flow of the program-

1- Connect with AX DB
2- Read table and get all the records.
3- Get docid - than get all the objectid for various pages.
4- Convert the objectids to filesystem path using the formula
5- Make a list of these files and check thier file extension using FileType Class which you can modify.
6- Convert them into PDF if they are tiff or merge them as per the file types.
7- Create the object in Docbase and attach the resulting file in STEP6 to the document and fill the attributes of document by the values which you retrived in STEP 2.

After coding this, you can run it from mulitple computers to make the migration faster and restrict the query result set based on DOCID .

NOTE- You should have access to the file system where AX files are stored as bin. Let me know how it goes.

I hope it helps.


Jar file to be download from internet and use in his code .

itextpdf-5.1.2.jar
jai_codec.jar
jai_core.jar
jai_windows-i586.jar
jmimemagic-0.1.0.jar
mlibwrapper_jai.jar
tika-app-0.9.jar

For source code, please comment on this blog , i will send you the source code.




Happy Migration

How to kill RDP session remotely ?

0

Category:

Use the command line tools to identify the open sessions and kill one of them. There are two tools, qwinsta and rwinsta. If you run "qwinsta /?" from a command shell, you will get the following:

qwinsta /?

Display information about Terminal Sessions.
QUERY SESSION [sessionname | username | sessionid]

[/SERVER:servername] [/MODE] [/FLOW] [/CONNECT] [/COUNTER]
  sessionname         Identifies the session named sessionname.

username Identifies the session with user username.
sessionid Identifies the session with ID sessionid.
/SERVER:servername The server to be queried (default is current).
/MODE Display current line settings.
/FLOW Display current flow control settings.
/CONNECT Display current connect settings.
/COUNTER Display current Terminal Services counters information.



If you run "rwinsta /?", you get the following:


rwinsta /?

Reset the session subsytem hardware and software to known initial values.

RESET SESSION {sessionname | sessionid} [/SERVER:servername] [/V]

sessionname Identifies the session with name sessionname.
sessionid Identifies the session with ID sessionid.
/SERVER:servername The server containing the session (default is current).
/V Display additional information.



For the sample server abc, you would run "qwinsta /server:abc"

Output


 SESSIONNAME       USERNAME                 ID  STATE   TYPE        DEVICE

console 0 Conn wdcon
rdp-tcp 65536 Listen rdpwd
abcd 1 Disc rdpwd
rdp-tcp#93 gates 3 Active rdpwd


From that output, we can take one of the IDs that was returned for the remote sessions and use rwinsta to kill that session. You would use something like:


rwinsta 1 /SERVER:abc


And that will terminate that session, allowing you to open a new session. You will need admin rights to run that command, but if you are using the admin terminal service connections to the server, then you would already have the necessary access rights to the server.


There is a third option, you can connect to the console session. This is the bonus option that I had referred to earlier. This is the session that you would get if you were physically in front of the server and were logging in on the server's mouse and keyboard. You can specify the console session as a command line parameter to the remote desktop client, mstsc.exe. The following syntax can be used to connect to the console session of a server:


mstsc /console

That feature will work with Server 2003 and later. On some machines, qwinsta and rwinsta may have been renamed to query.exe and reset.exe, respectively.

How to create two session to two different CS docbases?

0

Category: ,


Include both the docbroker in the dfc.properties.


public static IDfSession connectToDocbase1(String docbaseName,
String username, String passwd, String domain,
String docBrokerHost, String docBrokerPort) throws DfException {
try {
IDfSession session = null;
IDfClientX clientX = new DfClientX();
IDfClient client = clientX.getLocalClient();
IDfLoginInfo loginInfo = new DfLoginInfo();
loginInfo.setUser(username);
loginInfo.setPassword(passwd);
loginInfo.setDomain(domain);
if (docBrokerHost != null && docBrokerHost.length() > 0) {
IDfTypedObject apiconfig = client.getClientConfig();
String primaryHost = apiconfig.getString("primary_host");
String primaryPort = apiconfig.getString("primary_port");
apiconfig.setString("primary_host", docBrokerHost);
apiconfig.setString("primary_port", docBrokerPort);
try {
IDfTypedObject serverMap = client.getServerMapEx(
docbaseName, null, docBrokerHost, docBrokerPort);

session = client.newSession(docbaseName + "@"
+ serverMap.getString("i_host_name"), loginInfo);
} catch (DfException e) {
if (primaryHost != null) {
apiconfig.setString("primary_host", primaryHost);
}
if (primaryPort != null) {
apiconfig.setString("primary_port", primaryPort);
}
throw e;
}
apiconfig.setString("primary_host", primaryHost);
apiconfig.setString("primary_port", primaryPort);
} else {
session = client.newSession(docbaseName, loginInfo);
}
return session;
} catch (DfException ex) {
System.out.println("failed to connect " + ex.getMessage());
throw ex;
}
}

Vast amount of sessions from CTS causing CS to run out of memory error?

0

Category: , , ,

Following up on the webex, please try the steps below to clean up your

1. Unconfigure the docbase using MTS configuration program.
2. Uninstall MTS
3. Remove the remaining Documentum products from Add/Remove Programs.
4. Delete the following folders and all contents:
C:\Documentum
C:\Program Files\Documentum
5. Delete the Documentum entries from registry.
6. Reboot the MTS machine to make sure everything is clean.
7. Back up your custom profiles
8. Log in to DA as an admin user.
9. Delete the Media Server folder, located in: \System (select all children and all versions when prompted during delete)
10. Navigate to \System\Applications
11. Delete the CTSTransformRequest, MediaProfile, and Transformation folders if present
(including all versions and sub folders).
12. Navigate to the System\Modules\TBO folder
13. Delete all of the following folders (if present):
• dm_cts_response
• dm_media_profile
• dm_transform_request
• dmc_cts_reporting_config
• dmc_cts_request_archiving
14. Navigate to the System\Modules\SBO folder and:
• Delete all of the folders that start with "com.documentum.services.cts...";
• Delete all of the folders that start with "com.documentum.services.dam...".
15. Run the following two DQL statements against the docbase, in this order:
DQL> delete cts_instance_info object
DQL> drop type cts_instance_info

Restart docbase. Install MTS 6.5 SP3, install 2 DAR files, and then configure MTS against this docbase again to see if it fix your issue.

CTS service stops after starting on 6.5 sp3 and 6.6

0

Category:

The solutions for this problem deals with MS Windows 2008 server .



1. HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\DocumentumCTS\Parameters
AppParameters key

Make sure all the path to jre directory is complete and correct. If the path format is using complete path such as "C:\Program Files\Documentum\dctm.jar", try replacing it with short path like "C:\PROGRA~1\DOCUME~1\dctm.jar" in -Djava.class.path

Convert EXCEL,DOC,JPEG,PPT,BMP to PDF format using java code.

7

Category: , , , , ,

Perquisite to run this code,


1-Use Eclipse and java 1.5 or later
2-Download JODConvertor from the URL
3-http://code.google.com/p/jodconverter/downloads/list
4-Add all the jar file in lib directory of JODconvertor to your project.
5-Download Openoffice 3.0 from URL http://download.openoffice.org/other.html#tested-full
5-Install the Openoffice 3.0

Limitation
A:- It cannot be multi-threaded.
B:- It cannot convernt MULTI-TIFF images to PDF but it can convert single page TIFF to PDF.

import java.io.*;
import org.artofsolving.jodconverter.OfficeDocumentConverter;
import org.artofsolving.jodconverter.OfficeDocumentConverter.*;
import org.artofsolving.jodconverter.office.*;
import org.artofsolving.*;
import org.artofsolving.jodconverter.document.*;
import org.artofsolving.jodconverter.process.*;
import org.artofsolving.jodconverter.util.*;
public class Main {
public static void main(String[] args) throws Exception {
conversion();
}
public static void conversion(){
OfficeManager officeManager = new DefaultOfficeManagerConfiguration().buildOfficeManager();
officeManager.start();
OfficeDocumentConverter converter = new OfficeDocumentConverter(officeManager);
converter.convert(new File("C:/Temp/first.doc"), new File("C:/Temp/Doctest.pdf"));
officeManager.stop();
System.out.println("Hellow WOrld , its done");
}

Ask me if you are not able to run it.

Happy Conversion.

Manually uninstalling the Oracle from WinOS platform .

0

Category:

Manually uninstalling the Oracle from WinOS platform .

I had to do it for the Documentum installation and it sucks to do all these steps if you really mesh up the oracle installation. I did this to try some latest Documentum product testing and i noted down these steps if i need them in future or these can be of any help to anybody.No guarantee for any damage to system because these steps involve registry modifications and can really cause harm to your server if you try them on production environments(BE AWARE ). It was all hit and trial to re-install the oracle as oracle un-installer doesn't clean-up the system if you need to reinstall and it will be nightmare unless you really clean up the previous installations of oracle from the system.

A. Removing Components on Windows OS.
To remove all Oracle components from a computer on Windows OS:

1. Check privileges:
1.a. Ensure you are logged in as a user with Administrator privileges.

2. Stop all Oracle services (if any are running):
2.a. Right click My Computer > Manage > Services and Applications > Services

2.b. If any Oracle services (their names begin with Oracle) exist and have
the status Started, select the service and click Stop.

2.c. Click Close to exit the Services window.

2.d. Close the Control Panel/Computer Management window.

3. Remove the entries in the Windows registry:
3.a. Start the registry editor:
Choose Start > Run > regedt32

3.b. Go to HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE
Note the value of the key INST_LOC, this is the location of the Oracle Universal
Installer. The default location is Installation Drive(C:or D:):\Program Files\Oracle\Inventory. If this value is different, make note of it, so we can delete these files later.
Delete this ORACLE key.

3.c. Go to HKEY_LOCAL_MACHINE\SOFTWARE\ODBC and expand all subkeys and
remove all keys under here which are related with the
"Oracle ODBC Driver"

3.d. Go to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services and remove
all keys under here that begin with ORACLE or ORAWEB.

3.e. Go to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\...
\Application and remove all keys under here that begin with ORACLE.

3.f. Go to HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall
and remove any entries related to Oracle.

3.g. Go to HKEY_CLASSES_ROOT, remove all keys that begin with Oracle, OraPerf or
OraOLEDB

3.h. Close the registry.

4. Clean up the environment settings:
4.a. NT: Choose Start > Settings > Control Panel > System > Environment tab
2000: Choose Start > Settings > Control Panel > System > Advanced tab >
Environment variables.

4.b. At "System Variables" click on the variable PATH in order to modify
the value. For example, you may see a path similar to this one:
C:\ORACLE\ORA81\BIN;C:\PROGRAM FILES\ORACLE\JRE\1.1.7\BIN

4.c. If an %ORACLE_HOME% was installed, remove this %ORACLE_HOME%\BIN path.

4.d. If JRE was installed by Oracle, remove the JRE path.

4.e. If there is a CLASSPATH variable under "System Variables", first make note
of the path defined, then delete it. This variable can be added back at
a later date if needed.

4.f. Check if there are any other Oracle variables set in "System Variables",
ORACLE_HOME, ORACLE_SID or TNS_ADMIN. If these exist, delete them also.

4.g. Click on APPLY and OK.

4.h. Close the Control Panel window.

5. Delete the software and icons:
5.a.Choose Start > Programs > Accessories > Windows NT Explorer.

5.b. Go to SYSTEM_DRIVE:\WINNT\PROFILES\ALL USERS\START MENU\PROGRAMS
OR Go to SYSTEM_DRIVE:\DOCUMENTS AND SETTINGS\ALL USERS\START MENU\PROGRAMS


and delete the following icons:
- Oracle - HOME_NAME
where HOME_NAME is the previous Oracle home name.
- Oracle Installation Products

5.c. Go to SYSTEM_DRIVE:\Program Files\Oracle or the location of INST_LOC as
noted earlier in step 3.b and delete this directory.

5.d Go to SYSTEM_DRIVE:\Temp and delete all files and directories in here.

5.e. Go to the drive where the Oracle software is installed on your machine
and delete all ORACLE_BASE directories on your hard drive.

5.f. Close the Windows Explorer.

6. Finish the removal

7 Reboot your computer.

Perl Script to automate starting and stopping applications for Documentum Suite on All Unix based platforms.

0

Category:

Perl Script to automate starting and stopping applications for Documentum Suite on All Unix based platforms.


Please do changes as per your environment variables and path settings.

Put it onto your server and call it:
perl dmServices.pl


#!/usr/bin/perl
#########################WARNING-WARNING-WARNING#########################
# Use at your own RISK-please test it on your test environment before you
# jump onto the production .
#########################WARNING-WARNING-WARNING#########################

# Perl Modules required
# If you don't have these modules, this script will not run.
use strict;
use diagnostics;
use File::Basename;
use IPC::Open2;
use strict;
use diagnostics;
use Term::ANSIColor qw(:constants);

use vars qw (*INPUTP *PIPEOUT $CLIENTID $STOP $counter $path);

# Used to abort the script if set to 0;
$STOP = -1;

# Used for the data pipe
$CLIENTID = 0;

#$path = $ENV{'PWD'};
$path = "/tmp/docscript";

sub open_pipe
{
# Open the bi-directional data pipe which is very handy if
# we need to read the output from the command.

printf("Not working yet ... \n");
return;

my $cmd;
$cmd = $_[0];

$cmd='cd /opt;ls';

$CLIENTID = open2(\*PIPEOUT, \*INPUTP, $cmd);
if($CLIENTID == 0)
{ printf("CLIENTID = 0 ...\n");}

if(() eq '')
{ printf("PIPE Connection Error - Must Abort\n"); exit(1);}

printf("PIPE OPEN\n");
}

sub close_pipe
{
# Close all connections

close INPUTP;
close PIPEOUT;

# Kill of the PIPEID process
if($CLIENTID != 0 && kill 0 => $CLIENTID)
{ kill 9 => $CLIENTID;}

waitpid($CLIENTID, 0);
printf("PIPE PID has been terminated\n");
}

sub pipecmd
{
# Commands run through the data pipe
# Takes the input string and pipes out to execute the command

my $str;
$str = $_[0];

# Signal handler in case the pipe is broken.
$SIG{PIPE} = sub {printf("PIPEN has been broken - must Abort\n");};

print INPUTP "$str\n";
}

sub create_path
{
if (! -d $path)
{
my $localcmd;
$localcmd = "mkdir -p $path";
system($localcmd);
}
if (! -d $path) {printf("$path could not be created.\n");exit(0);}
}

sub remove_path
{
if (-d $path)
{
my $localcmd;
my $dir;
$dir = basename $path;
$localcmd = "cd /tmp;rm -rf $dir";
system($localcmd);
}
}

sub promptUser
{
my ($promptString,$defaultValue);
($promptString,$defaultValue) = @_;

$promptString = "->" unless defined $promptString;
$defaultValue = "->" unless defined $defaultValue;

if ($defaultValue) {
print $promptString, "[", $defaultValue, "]: ";
} else {
print $promptString, ": ";
}

$| = 1; # force a flush after our print

# If no activity on the prompt for 2 mins then set the interrupt
# to alarm and we will exit.
eval
{
local $SIG{ALRM} = sub {printf("No activity for 2 mins - Doc Services aborts\n"); exit(0);};
alarm 120;
eval
{
$_ = ; # get the input from STDIN (presumably the keyboard)
# Remove '\n'
chomp;
};
alarm 0;
};
alarm 0;

$_ = 'noentry' unless defined $_;
if($_ =~ /[a-z]/ || $_ =~ /[A-Z]/) {
# This is text;
return $_;
}

if($_ == 0) {return 0;}
if ("$defaultValue") {
return $_ ? $_ : $defaultValue; # return $_ if it has a value
} else {
return $_;
}

}
######################################################################
### Main
######################################################################

&input_handler();
exit(0);

######################################################################
### Subroutines
######################################################################
sub input_handler
{

my $done;
$done = 0;
my ($action, $indicator, $userid);

$userid = getpwuid($>);

while($done == 0)
{
system("clear");

&setupSigHdlrs();
$action =0;

printf("--------------------------------------------\n");
printf(" Welcome $userid to DOC SERVICES\n");
printf("--------------------------------------------\n");
if($userid ne "docinst")
{
printf("--> CURRENT USERID: $userid\n");
printf("---------------------------------------------------\n");
printf("WARNING: To perform maintenance activities on\n");
printf("DOCUMENTUM you MUST be logged in as userid: docinst\n");
printf("otherwise any processes you start or stop will not\n");
printf("operate properly.\n\n");
printf("**********YOUR SESSION IS BEING ABORTED.***********\n");
printf("---------------------------------------------------\n");
exit(0);
}
printf("Please choose one of the options:\n\n");
printf(" --> 1. START Documentum services.\n");
printf(" --> 2. STOP Documentum services.\n");
printf(" --> 3. QUERY Documentum processes.\n");
printf(" --> 4. START Application Server.\n");
printf(" --> 5. START Method Server.\n");
printf(" --> 6. STOP Application Server.\n");
printf(" --> 7. STOP Method Server.\n");
printf(" --> 8. QUERY JAVA Server Process.\n");
printf(" --> 9. START Oracle 10g Server.\n");
printf(" -->10. START Oracle DB Console.\n");
printf(" -->11. STOP DOCBROKER.\n");
printf(" -->12. START DOCBROKER.\n");
printf(" -->13. STOP FULLTEXT SERVER/AGENT.\n");
printf(" -->14. START FULLTEXT SERVER/AGENT.\n");
printf(" -->15. QUERY Index Node Controller.\n");
printf("--------------------------------------------\n");
printf(" --> QUIT: CTRL ^C\n");
printf("--------------------------------------------\n");
printf("--------------------------------------------\n");
$action = &promptUser("Enter numeric option: (1-14): \n");

&setenv_vars();

if($action == 1)
{
system("clear");
&startup_services();
}
elsif($action == 2)
{
system("clear");
&stop_services();
}
elsif($action == 3)
{
system("clear");
my $input = "query";
&terminate_processes($input);
}
elsif($action == 4)
{
system("clear");
my $input = 1;
&handle_apache_server($input);
}
elsif($action == 5)
{
system("clear");
my $input = 4;
&handle_apache_server($input);
}
elsif($action == 6)
{
system("clear");
my $input = 2;
&handle_apache_server($input);
}
elsif($action == 7)
{
system("clear");
my $input = 3;
&handle_apache_server($input);
}
elsif($action == 8)
{
system("clear");
my $input = "java";
&terminate_processes($input);
}
elsif($action == 9)
{
system("clear");

printf("Manually perform the following:\n");
printf(" --> su - oracle\n");
printf(" --> password: oracle1\n");
printf(" --> cd \$ORACLE_HOME\n");
printf(" --> bin/sqlplus /nolog\n");
printf(" --> connect SYS as SYSDBA\n");
printf(" --> oracle1\n");
printf(" --> startup\n");
printf(" --> quit\n");

}
elsif($action == 10)
{
system("clear");

printf("Manually perform the following:\n");
printf(" --> su - oracle\n");
printf(" --> password: oracle1\n");
printf(" --> cd \$ORACLE_HOME\n");
printf(" --> bin/emctl start dbconsole\n");

}
elsif($action == 11)
{
system("clear");
&stop_dmdocbroker();
}
elsif($action == 12)
{
system("clear");
&check_dmdocbroker();
}
elsif($action == 13)
{
system("clear");
&stop_fulltext();
}
elsif($action == 14)
{
system("clear");
&start_fulltext();
}
elsif($action == 15)
{
system("clear");
&get_nctrl();
}

$action = &promptUser("Would you like to exit ?\n");
$action = lc($action);
if($action eq 'y')
{
printf("\n\n\n\n\nTHANK YOU FOR USING DOC SERVICES.\n");
$done = 1;
}
$action = 0;
}}

sub start_oracle
{
printf("Functionality not working yet ...\n");

# Will start the Oracle database or DBconsole
my $inputstr;
$inputstr = $_[0];

&open_pipe();
sleep(1);
&pipecmd("su - oracle;oracle1");

# Setup the environment variables
# $ENV{'ORACLE_HOME'} = '/opt/oracle/oracle/product/10.2.0/db_1';

if($inputstr eq "startup")
{
printf("Performing Oracle Startup ...\n");

# Send in the SQL commands to start up the database
&pipecmd("cd \$ORACLE_HOME;bin/sqlplus /nolog");
&pipecmd("");

while()
{
if(/SQL>/i)
{
# We are in
&pipecmd("connect SYS as SYSDBA");

# Need to sleep 2 secs or we will send in the password before the prompt
# is ready.
sleep(2);
&pipecmd("oracle1");
next;
}
if(/Connected./i)
{
&start_oracle_server();
last;
}
}

sleep(2);
}
if($inputstr eq "console")
{
printf("Performing DBCONSOLE Startup ...\n");

&start_oracle_dbconsole();
}
}

sub start_oracle_server
{
&pipecmd("startup");

while()
{
printf("STARTUP: $_");
}
&pipecmd("quit");
}

sub start_oracle_dbconsole
{
# Startup the oracle database console
&pipecmd("bin/emctl start dbconsole");
while()
{
printf("DBCONSOLE: $_");
}
}

sub terminate_processes
{
# User has the option of passing in parmeter 'query' or 'java' which will
# output processes instead of killing them.

&create_path();
my $pidout = "$path\/pidout.txt";


$counter = 0;

my $input;
$input = $_[0];
$input = 'null' unless defined $input;

my ($pidcnt, $asked, $localcmd, $printonce, $index);
$asked = 'q';
$printonce = 0;
$pidcnt = 0;
$index = 9;

$localcmd = "/bin/ps -fU docinst > $pidout";
system($localcmd);


open(PIDOUT, "< $pidout");
while()
{
if($input eq "java")
{
if($_ =~ /.\/java/i)
{
if ($printonce == 0)
{
printf("\n\n******* DOC Services QUERY JAVA Report *******\n");
$printonce = 1;
}
printf("JAVA: $_\n");
$pidcnt ++;
}
next;
}
if($_ =~ /.\/documentum/i ||
$_ =~ /.\/dmdocbroker/i)
{
$counter ++;

# Documentum processes are still alive.
my @psarray;
undef(@psarray);
@psarray = split(/ /, $_);
#$psarray[2] =~ s/\S+$//;
#$psarray[2] =~ s/^\S+//;
my $i;
for($i=0;$i<=5;$i++)
{
my $value;
$value = $psarray[$i];
if($value =~ s/\d+$//)
{ $index=$i;last;}
}
if ($index >= 5) {printf("Invalid PID ... skipping\n"); next;}
if ($input eq 'query')
{
if ($printonce == 0)
{
printf("\n\n******* DOC Services QUERY Report *******\n");
$printonce = 1;
}
printf("Owner: $psarray[1] PID: $psarray[$index]\n $_\n");
$pidcnt = $counter;
next;
}

if ($asked eq 'q' || $asked eq 'n')
{
$asked = &promptUser("One of more Documentum processes found\n Would you like to terminate ALL ?\n\n");
$asked = lc($asked);
}

if ($asked eq 'y')
{
printf("Terminating process: $psarray[1] : $psarray[$index]\n");
$localcmd = "kill $psarray[$index]";
my $rc = system($localcmd);
if ($rc != 0)
{
printf("[FAILED] Could not terminate process: $psarray[$index]\n");
$STOP = 0;
}
else
{
$counter = $counter -1;
}
}
else
{
printf("[INFO] Process: $psarray[1] : $psarray[$index] lives\n");
$STOP = 0;
}
printf("[INFO] Documentum processes still alive: $counter.\n");
$pidcnt = $counter;
}
}
close(PIDOUT);
if($pidcnt == 0) {printf("\n\nNO PROCESSES FOUND\n");}
&remove_path();
}

sub setupSigHdlrs
{
# Re-define any signal handlers, as necessary.

# Catch Ctrl-C
$SIG{INT} = \&HandleCtrlC;

}

sub HandleCtrlC
{
# A cleanup routine called when the user types ctrl-C.
if($CLIENTID != 0)
{
#&close_pipe();
}
printf("\nControl ^C encountered - exiting.\n");
exit()
}

sub startup_services
{
# start the documentum services
my $localcmd;

printf("INITIATE STARTUP ...\n\n");

# Check for documentum processes
&terminate_processes();

printf(" CHECKING safety indicator ...\n");
# Check if safe to proceed.
&check_safety();

&setenv_vars();
# Added this here as it seems to work instead of letting the
# dm_start_dbdoc_sh19necm1_r01 script try to bring it up.
printf(" STARTING DM_DOCBROKER ...\n\n\n");
system("cd /opt/documentum/dba;./dm_launch_Docbroker");
sleep(2);

printf("\n\n STARTING DATABASE: dbdoc_sh19necm1_r01 ...\n\n\n");
# Repository
$localcmd = ('cd /opt/documentum/dba;./dm_start_dbdoc_sh19necm1_r01');
system($localcmd);

# Start Tomcat for web services.
&handle_apache_server(1);

# Start Method Server.
#&handle_apache_server(4);

&start_fulltext();

&check_dmdocbroker();

printf("\n\n\n\n");
printf("=======================================================\n");
printf("NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE\n");
printf("=======================================================\n");
printf("You must close your browser and restart using the static\n");
printf("IP address for the DOCUMENTUM services to connect to.\n");
printf("Failure to do so will RESULT in no connectivity.\n");
printf("=======================================================\n");

printf("\n\nSTARTUP INITIATE COMPLETED.\n");
}

sub start_fulltext
{
my $localcmd;

printf(" \n\n STARTING INDEX SERVER ...\n\n\n");
#Index Server
$localcmd = ('cd /opt/documentum/fulltext/IndexServer/bin;./startup.sh');
system($localcmd);

printf(" \n\n STARTING INDEX AGENT ...\n\n\n");
# Index Agent
$localcmd = ('cd /opt/documentum/shared/IndexAgents/IndexAgent1;./startupIndexAgent.sh');
system($localcmd);

&get_nctrl();

}

sub get_nctrl
{
my $localcmd;

printf("Obtaining Node Controller status Info ...");
sleep(3);
$localcmd = ('cd /opt/documentum/fulltext/IndexServer/bin; nctrl sysstatus');
system($localcmd);
}

sub handle_apache_server
{
# Handler to start or stop application server or
# Documentum Method Server.
# INPUT: 1 = START APPLICATION SERVER
# 2 = STOP APPLICATION SERVER
# 3 = STOP METHOD SERVER
# 4 = START METHOD SERVER

my ($localcmd,$input);
$input = $_[0];

if ($input == 1)
{
printf(" STARTING APACHE TOMCAT services ...\n");
# Tomcat for web services.
$ENV{'CATALINA_HOME'} = '/opt/apache/tomcat';
$ENV{'CATALINA_BASE'} = '/opt/apache/tomcat';
$localcmd = 'cd /opt/apache/tomcat/bin;./startup.sh';
system($localcmd);
}
if ($input == 2)
{
printf(" STOPPING APACHE TOMCAT services ...\n");
# Tomcat for web services.
$ENV{'CATALINA_HOME'} = '/opt/apache/tomcat';
$ENV{'CATALINA_BASE'} = '/opt/apache/tomcat';
$localcmd = 'cd /opt/apache/tomcat/bin;./shutdown.sh';
system($localcmd);
}
if ($input == 3)
{
printf(" STOPPING Documentum Method Server ...\n");
printf("\n\n THIS IS NOT RECOMMENDED !!!\n");

$ENV{'CATALINA_HOME'} = '/opt/documentum/shared/tomcat/5.0.28';
$ENV{'CATALINA_BASE'} = '/opt/documentum/shared/tomcat/5.0.28';
$localcmd = 'cd /opt/documentum/shared/tomcat/5.0.28/bin;./shutdown.sh';
system($localcmd);
}
if ($input == 4)
{
printf(" STARTING Documentum Method Server ...\n");
printf("\n\n THIS IS NOT RECOMMENDED !!!\n");
printf(" COMMAND CANCELLED.\n");
$ENV{'CATALINA_HOME'} = '/opt/documentum/shared/tomcat/5.0.28';
$ENV{'CATALINA_BASE'} = '/opt/documentum/shared/tomcat/5.0.28';
$localcmd = 'cd /opt/documentum/shared/tomcat/5.0.28/bin;./startup.sh';
system($localcmd);
}
}
sub check_dmdocbroker
{
my $found;
$found = -1;
&create_path();
system("/bin/ps -ef > $path\/dmdocb.txt");
open(DMOUT, "< $path\/dmdocb.txt");
while()
{
if($_ =~ /.\/dmdocbroker/i)
{
$found = 0;
last;
}
}
close(DMOUT);
&remove_path();
if($found != 0)
{
my $action;
printf("Docbroker failed to start therefore\n");
$action = &promptUser("would you like to start manually ?\n");
$action = lc($action);
if ($action eq 'y')
{
&setenv_vars();
# Docbroker failed to start so kick it manually.
system("cd /opt/documentum/dba;./dm_launch_Docbroker");
printf("\n**DM_DOCBROKER STARTED MANUALLY FROM SCRIPT**\n");
}
else { printf("\n**Please investigate DOCBROKER LOG\n /opt/documentum/dba/log/docbroker...**\n");}
}
}

sub stop_dmdocbroker
{
my $localcmd;

printf(" Stopping DM DOCBROKER ...\n");
$localcmd = 'cd /opt/documentum/dba;./dm_stop_Docbroker';
system($localcmd);
}

sub stop_services
{
my $localcmd;

printf("SHUTDOWN INITIATING ...\n\n");
sleep(2);

&stop_fulltext();

sleep(2);
# Stop Apache and Documentum Method Server
# &handle_apache_server(3); <-- This causes errors so don't do
&handle_apache_server(2);

printf(" Stopping repository ...\n");
$localcmd = 'cd /opt/documentum/dba;./dm_shutdown_dbdoc_sh19necm1_r01';
system($localcmd);

&stop_dmdocbroker();

sleep(5);
# Check for any documentum processes
&terminate_processes();

}

sub stop_fulltext
{
my $localcmd;

printf(" Stopping Index Agent ...\n");
$localcmd = 'cd /opt/documentum/shared/IndexAgents/IndexAgent1;./shutdownIndexAgent.sh';
system($localcmd);

printf(" Stopping Index Server ...\n");
$localcmd = 'cd /opt/documentum/fulltext/IndexServer/bin;./shutdown.sh';
system($localcmd);

&get_nctrl();
}

sub check_safety
{

if ($STOP == 0 && $counter > 0)
{
# Not safe to continue.
printf("ERROR: It is unsafe to continue ... \n");
printf(" Check for previous errors!\n\n");
exit(0);
}
}

sub setenv_vars
{
# Setup the environment just in case we are not being called from
# a profile that has the proper ENV.
$ENV{'ORACLE_SID'} = 'DBDOC';
$ENV{'DOCUMENTUM_SHARED'} = '/opt/documentum/shared';
$ENV{'LD_LIBRARY_PATH'} = '/opt/documentum/fulltext/IndexServer/lib:/opt/documentum/fulltext/fast40:/opt/documentum/shared/dfc:/opt/documentum/shared/IndexAgents/ftintegrity';
$ENV{'LC_ALL'} = 'C';
$ENV{'FASTSEARCH'} = '/opt/documentum/fulltext/IndexServer';
$ENV{'JAVA_HOME'} = '/opt/documentum/shared/java/1.4.2_11';
$ENV{'ORACLE_BASE'} = '/opt/oracle/oracle/product/10.2.0/db_1';
$ENV{'ORACLE_HOME'} = '/opt/oracle/oracle/product/10.2.0/db_1';
$ENV{'DISPLAY'} = 'localhost:1';
$ENV{'DM_HOME'} = '/opt/documentum/product/5.3';
$ENV{'LOGNAME'} = 'docinst';
$ENV{'DOCUMENTUM'} = '/opt/documentum';
$ENV{'PATH'} = '/usr/bin::/usr/local/bin:/usr/openwin/bin';
$ENV{'TNS_ADMIN'} = '/opt/oracle/oracle/product/10.2.0/db_1/network/admin';
}

JAVA-DB Connectivity

0

Category:

Introduction


JDBC is a set of classes and interfaces written in Java that allows Java programs to access a database. IBM has several types of JDBC drivers, this how-to is refering to IBM's DB2 type 4 thin driver.

Download driver package


At the time of testing, I got a package called db2_jdbc_t4_fp13.zip from www.ibm.com. We can verify the content of the file:

jar -tf db2_jdbc_t4_fp13.zip fm@susie112:~> /usr/java/jdk1.5.0_09/bin/jar tf db2_jdbc_t4_fp13.zip db2_jdbc_t4_fp13/ db2_jdbc_t4_fp13/db2jcc.jar db2_jdbc_t4_fp13/db2jcc_javax.jar db2_jdbc_t4_fp13/db2jcc_license_cu.jar db2_jdbc_t4_fp13/sqlj.zip

Install the driver package


In order to work with the driver, Java must be able to find it when called. We can achieve this by adding the drivers zip file location to the Java classpath, or by simply placing the driver file into the Java standard directory for extensions, for JAVA JRE this is the $JAVA_HOME/jre/lib/ext (i.e. /usr/lib64/jvm/jre-1.6.0-ibm/lib/ext) directory. We need to copy the extracted db2_jdbc_t4_fp13/db2jcc.jar and db2_jdbc_t4_fp13/db2jcc_license_cu.jar.

Use the driver to access DB2 through Java


The following example code JdbcTestDB2.java can be used to quickly access and test the JDBC connection.

vi JdbcTestDB2.java //JdbcTestDB2.java import java.sql.Connection ; import java.sql.DriverManager ; import java.sql.ResultSet ; import java.sql.Statement ; import java.sql.SQLException;  class JdbcTestDB2 {   public static void main (String args[]) {       try {         // use the JDBCtype 4 driver         Class.forName("com.ibm.db2.jcc.DB2Driver");       }       catch (ClassNotFoundException e) {             System.err.println (e) ;             System.exit (-1) ;       }       try {          Connection connection = DriverManager.getConnection(          // open connection to database          // "jdbc:db2://destinationhost:port/dbname", "dbuser", "dbpassword"          // the DB2 internal data catalog is in a database called "toolsdb"          "jdbc:db2://localhost:50002/SAMPLE", "db2inst1", "password1");            // build query, use table "ENV_INST_INFO" in schema "SYSIBM"           String query = "select INST_NAME from SYSIBMADM.ENV_INST_INFO" ;            // execute query           Statement statement = connection.createStatement () ;           ResultSet rs = statement.executeQuery (query) ;            // return query result           while ( rs.next () )               System.out.println ("DB2 Query result: " + rs.getString (1)) ;           connection.close () ;       }       catch (java.sql.SQLException e) {           System.err.println (e) ;           System.exit (-1) ;         }     } }  fm@susie112:~> javac JdbcTestDB2.java  fm@susie112:~> java JdbcTestDB2 DB2 Query result: db2inst1

Should this test fail, typical reasons are:

  • Wrong database port? DB2 typically uses ports 50000 and up
  • Wrong database user, or database user does not have admin rights
  • The test program tries to access the database "sample", it can be installed using the command 'db2sampl'

Java code to connect DB2 Type 4 driver

0

Category:

Java code to connect DB2 Type 4 driver db2jcc.jar

JAVA sample code to connect to DB2 Database using Type 4 Driver

The below sample code shows the simple way of making connection to a DB2 Server Database exists on a remote machine with out installing any db2 client on your machine. But all we need to have is Type 4 drivers to make this connection which we can use by pointing to thedb2jcc.jar and db2jcc_license_cu.jar.
All we need to do is point the java class path to find this jars, in case of eclipse users configure the build path and these 2 jars as external jars from the path they located to the project. change the Host name, port, user name and password like details in the below program and run accordingly.

Syntax for the connection string :
DriverManager.getConnection
("jdbc:db2j:net://<HOSTNAME>:/,">","");

Sample connection string :
DriverManager.getConnection
("jdbc:db2j:net://nc184120.tivlab.austin.ibm.com:50001/CDSDB","db2inst1","db2inst1");
The following is the sample code

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class Java2DB2 {
public static void main(String[] args)
{
try
{
// load the DB2 Driver
Class.forName("com.ibm.db2.jcc.DB2Driver");
// establish a connection to DB2
Connection db2Conn =
DriverManager.getConnection
("jdbc:db2j:net://nc184120.tivlab.austin.ibm.com:50001/CDSDB","db2inst1","db2inst1");
// use a statement to gather data from the database
Statement st = db2Conn.createStatement();
String myQuery = "SELECT * FROM CDSSCHEMA.ACL_ADMIN";
// execute the query
ResultSet resultSet = st.executeQuery(myQuery);
// cycle through the resulSet and display what was grabbed
while (resultSet.next())
{
String name = resultSet.getString("USER_NAME");
String id = resultSet.getString("USER_ID");
System.out.println("User Name: " + name);
System.out.println("User ID: " + id);
System.out.println("-------------------------------");
}
// clean up resources
resultSet.close();
st.close();
db2Conn.close();
}
catch (ClassNotFoundException cnfe)
{
cnfe.printStackTrace();
}
catch (SQLException sqle)
{
sqle.printStackTrace();
}
}
}