Subversion Repositories DevTools

Rev

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

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