Subversion Repositories DevTools

Rev

Rev 399 | Rev 4545 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 399 Rev 4466
Line 35... Line 35...
35
our @EXPORT = qw();
35
our @EXPORT = qw();
36
our @EXPORT_OK = (@EXPORT, qw());
36
our @EXPORT_OK = (@EXPORT, qw());
37
our %EXPORT_TAGS = qw( );
37
our %EXPORT_TAGS = qw( );
38
our $verbose = $ENV{'GBE_DBI_VERBOSE'} || 0;
38
our $verbose = $ENV{'GBE_DBI_VERBOSE'} || 0;
39
our $errstr = "No Error";
39
our $errstr = "No Error";
-
 
40
my %appnames = (
40
my  $appname = 'ReleaseManagerSelect.jar';
41
                'jdbc:oracle:'  => 'ReleaseManagerSelect.jar',
-
 
42
                'jdbc:jtds'     => 'ClearQuestSelect.jar'
41
my $full_app;
43
                );
42
 
44
 
43
#
45
#
44
#   The following hash simplifies existing code
46
#   The following hash simplifies existing code
45
#   in that it will convert known DBI:ODBC called to a more raw form
47
#   in that it will convert known DBI:ODBC called to a more raw form
46
#
48
#
Line 61... Line 63...
61
#
63
#
62
sub connect
64
sub connect
63
{
65
{
64
    my $obclass = shift;
66
    my $obclass = shift;
65
    my $class = ref($obclass) || $obclass;
67
    my $class = ref($obclass) || $obclass;
-
 
68
    my $full_app;
66
 
69
 
67
    bless my $self = {
70
    bless my $self = {
68
        DB          => $_[0],
71
        DB          => $_[0],
69
        USER        => $_[1],
72
        USER        => $_[1],
70
        PASSWORD    => $_[2],
73
        PASSWORD    => $_[2],
Line 97... Line 100...
97
            if $verbose > 1;
100
            if $verbose > 1;
98
        $self->{DB} = $value;
101
        $self->{DB} = $value;
99
    }
102
    }
100
 
103
 
101
    #
104
    #
-
 
105
    #   Determine the underlying Java program
-
 
106
    #
-
 
107
    foreach my $entry ( keys %appnames) {
-
 
108
        if ( $self->{DB} =~ m~^$entry~){
-
 
109
            $self->{APPNAME} = $appnames{$entry};
-
 
110
        }
-
 
111
    }
-
 
112
    unless (defined $self->{APPNAME})
-
 
113
    {
-
 
114
        $errstr = "Cannot determine driver for URL";
-
 
115
        return;
-
 
116
    }
-
 
117
 
-
 
118
    print "[DBI] Using Driver: " . $self->{APPNAME} ."\n"
-
 
119
        if $verbose > 1;
-
 
120
 
-
 
121
    #
102
    #   Need to locate the path to the Java applet
122
    #   Need to locate the path to the Java applet
103
    #   This can be in th "CLASSPATH", but that simply forces the problem of
123
    #   This can be in th "CLASSPATH", but that simply forces the problem of
104
    #   locating the utility into the configuration world
124
    #   locating the utility into the configuration world
105
    #
125
    #
106
    #   Look in Perls @INC list, as we expect to find the program within one of
126
    #   Look in Perls @INC list, as we expect to find the program within one of
Line 108... Line 128...
108
    #
128
    #
109
    unless ( $full_app )
129
    unless ( $full_app )
110
    {
130
    {
111
        foreach my $dir ( @INC )
131
        foreach my $dir ( @INC )
112
        {
132
        {
113
            my $apppath = "$dir/$appname";
133
            my $apppath = "$dir/$self->{APPNAME}";
114
            next unless ( -f $apppath );
134
            next unless ( -f $apppath );
115
 
135
 
116
            $full_app = $apppath;
136
            $full_app = $apppath;
117
            last;
137
            last;
118
        }
138
        }
119
 
139
 
120
        if ( ! $full_app )
140
        if ( ! $full_app )
121
        {
141
        {
122
            $errstr = "Cannot find $appname in @INC path";
142
            $errstr = "Cannot find $self->{APPNAME} in @INC path";
123
            return;
143
            return;
124
        }
144
        }
125
    }
145
    }
-
 
146
    print "[DBI] Using Driver from: " . $full_app ."\n"
-
 
147
        if $verbose > 1;
126
 
148
 
127
    $errstr = "OK";
149
    $errstr = "OK";
128
 
150
 
129
    #
151
    #
130
    #   Initiate the external application server
152
    #   Initiate the external application server