Schrift
[thread]12136[/thread]

Oracle: wie heißt eigentlich meine Datenbank?

Leser: 1


<< >> 5 Einträge, 1 Seite
pktm
 2008-07-05 12:37
#111877 #111877
User since
2003-08-07
2921 Artikel
BenutzerIn
[Homepage]
user image
Hallo!

Ich würde gerne zu meiner Oracle-Datenbank hier eine Verbindung aufbauen. Aber: dazu muss man den Namen der Datenbank angeben. Und enau an dieser Stelle stehe ich auf dem Schlauch.

Ich kann zwar über die Administrationsoberfläche viele Infos abrufen, aber wie ist denn eigentlich der Name von der Datenbank? Wo steht der?

Hier mal exakt was ich benötige:
Code: (dl )
1
2
3
4
5
6
my $dbh = DBI->connect( 'dbi:Oracle:<<DAS_HIER>>',
'user',
'pass',
) || die "Database connection not made: $DBI::errstr";

$dbh->disconnect();


Grüße, pktm
http://www.intergastro-service.de (mein erstes CMS :) )
Gast Gast
 2008-07-05 17:51
#111884 #111884
Note:
For UNIX or Linux, the platform-specific default location (directory) for the SPFILE and text initialization parameter file is:

$ORACLE_HOME/dbs


For Windows NT and Windows 2000 the location is:

%ORACLE_HOME%\database

In the platform-specific default location, Oracle Database locates your initialization parameter file by examining filenames in the following order:

1.

spfile$ORACLE_SID.ora
2.

spfile.ora
3.

init$ORACLE_SID.ora

The first two filenames represent SPFILEs and the third represents a text initialization parameter file.
jan10001
 2008-07-07 14:05
#111904 #111904
User since
2003-08-14
962 Artikel
BenutzerIn
[default_avatar]
Bei Oracle steht das eigentlich auf der ersten Seite.

Oder unter Windows "sqlplus / as sysdba" aufrufen und dort ein "select name from v$database;" ausführen.

Anmerkung: Standart DB Name bei Oracle ist meist ORCL
pktm
 2008-07-07 19:34
#111919 #111919
User since
2003-08-07
2921 Artikel
BenutzerIn
[Homepage]
user image
Hm...
also select name from v$database; liefert mir XE, im dsn hab ich jetzt aber localhost stehen. Das geht auch :-s

Ich muss gestehen, dass ich es durch wüstes herumspielen geschafft habe mein Programm mit der Datenbank zu verbinden.

Wer will, hier der Code:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
#!/usr/bin/perl

use warnings;
use strict;

# Tk support is enabled if the Tk module is used before POE itself.
use Tk;
use POE;
use POE qw( Component::EasyDBI );

use Data::Dumper qw/Dumper/;
use Perl6::Say;


# -- Set up the DBI
POE::Component::EasyDBI->spawn( # or new(), witch returns an obj
alias => 'EasyDBI',
dsn => 'dbi:Oracle:localhost',
username => 'username',
password => 'password',
options => {
AutoCommit => 0,
},
);



# -- Create the session that will drive the user interface.
POE::Session->create(
inline_states => {
_start => \&ui_start,
ev_count => \&ui_count,
ev_clear => \&ui_clear,
get_some_data => \&get_some_data,
dummy_result_handler => \&dummy_result_handler,
},
);

# Run the program until it is exited.

$poe_kernel->run();
exit 0;

=head2 METHODEN

=head3 ui_start( ??? )

Create the user interface when the session starts. This assumes
some familiarity with Tk. ui_start() illustrates four important
points.

1. Tk events require a main window. POE creates one for internal
use and exports it as $poe_main_window. ui_start() uses that as the
basis for its user interface.

2. Widgets we need to work with later, such as the counter display,
must be stored somewhere. The heap is a convenient place for them.

3. Tk widgets expect callbacks in the form of coderefs. The
session's postback() method provides coderefs that post events when
called. The Button created in ui_start() fires an "ev_clear" event
when it is pressed.

4. POE::Kernel methods such as yield(), post(), delay(), signal(),
and select() (among others) work the same as they would without Tk.
This feature makes it possible to write back end sessions that
support multiple GUIs with a single code base.

=cut

sub ui_start {
my ( $self, $kernel, $session, $heap ) = @_[ OBJECT, KERNEL, SESSION, HEAP ];

# ------------------------------------------------------------
# - Initialisierung

# ------------------------------------------------------
# -- Test: etwas Inhalt einfügen
# ...
# ------------------------------------------------------
$heap->{testlabel} = $poe_main_window->Label(-text => 'start')->pack();

# ------------------------------------------------------------
# - Statusbar
# -> für den UI-Counter
require Tk::StatusBar;
$heap->{statusbar} = $poe_main_window->StatusBar();
$heap->{statusbar}->addLabel(
-relief => 'flat',
-text => "Welcome to the statusbar",
);

$heap->{statusbar}->addLabel(
-text => 'Frame:',
-width => '10',
-anchor => 'center',
);

$heap->{statusbar}->addLabel(
-width => 20,
-anchor => 'center',
-textvariable => \$heap->{counter},
-foreground => 'blue',
);

$heap->{statusbar}->addLabel(
-width => 10,
-anchor => 'center',
-text => "Clear",
-foreground => 'blue',
-command => $session->postback("ev_clear"),
-event => '<Button-1>',
);

# ------------------------------------------------------------
# - Test-Zeug
testzeug( $heap, $poe_main_window );

say "yield2get_some_data";
$kernel->yield('get_some_data');

say "yield2ev_count";
$kernel->yield("ev_count");
} # /ui_start





=head3 testzeug( $heap, $poe_main_window )

Dient dazu diverses Testzeug auszuführen, z.B: Debugging.
Bei Auslieferung des Programms sollte diese Funktion nichts mehr machen, aber
dennoch enthalten sein damit man später mal schnell was debuggen kann.

=cut

sub testzeug {
my $heap = shift;
my $mw = shift;



} # /testzeug




=head2 ui_count( ??? )

Handle the "ev_count" event by increasing a counter and displaying
its new value.

=cut

sub ui_count {
my ($self, $kernel, $heap) = @_[OBJECT, KERNEL, HEAP];

$heap->{counter}++;

$kernel->yield("ev_count");
} # /ui_count




=head2 ui_clear

Handle the "ev_clear" event by clearing and redisplaying the
counter.

=cut

sub ui_clear {
$_[HEAP]->{counter} = 0;
} # /ui_clear




=head2 dummy_result_handler( ... )

$_[ARG0] = {
sql => The SQL you sent
result => hash ref of hash refs keyed on primary key
placeholders => The placeholders
action => 'hashhash'
cols => array of columns in order (to help recreate the sql order)
error => Error occurred, check this first
result => ... result varies ...
}
print Dumper $_[ARG0]->{sql};

=cut

sub dummy_result_handler {
my ($self, $kernel, $heap) = @_[OBJECT, KERNEL, HEAP];

$heap->{testlabel}->configure(-text => $_[ARG0]->{result}->{CurrentTime});

print Dumper $_[ARG0];

$kernel->delay( 'get_some_data' => 2 );

} # /dummy_result_handler




=head2 get_some_data( ... )

Fetch some data here

=cut

sub get_some_data {
my ($self, $kernel, $heap) = @_[OBJECT, KERNEL, HEAP];

#say "get_it";

$kernel->post( 'EasyDBI',
hash => {
sql => q{select to_char(sysdate, 'Dy DD-Mon-YYYY HH24:MI:SS') as "CurrentTime" from dual},
event => 'dummy_result_handler',
}
);

} # /get_some_data





=head1 QUELLEN

http://poe.perl.org/?POE_Cookbook/Tk_Interfaces

This sample program creates a very simple Tk counter. Its interface
consists of three widgets: A rapidly increasing counter, and a
button to reset that counter.

=cut
http://www.intergastro-service.de (mein erstes CMS :) )
Gast Gast
 2008-07-08 13:41
#111933 #111933
Hallo,

man muß den Datenbanknamen nur angeben, wenn mehrere Datenbanken auf dem gleichen Rechner laufen.

Wenn auf dem Rechner nur eine einzelne Datenbank läuft ist diese default

Der Datenbankname ist gleich der Umgebungsvariablen ORACLE_SID

Auf Unix-Systemen haben die Datenbank-Prozesse als Anhang den DB-Namen

also z.B. für eine ORACLE_SID=oss

oracle 22810 1 0 Jun 4 ? 7:40 oracleoss (DESCRIPTION=(LOCAL=NO)(SDU=5844))
oracle 22698 1 0 Jun 4 ? 0:00 oracleoss (DESCRIPTION=(LOCAL=NO)(SDU=5844))
oracle 22714 1 0 Jun 4 ? 0:00 oracleoss (DESCRIPTION=(LOCAL=NO)(SDU=5844))
oracle 22873 1 0 Jun 4 ? 0:00 oracleoss (DESCRIPTION=(LOCAL=NO)(SDU=5844))
oracle 22135 1 0 Jun 4 ? 7:54 ora_dbw4_oss
oracle 9888 1 0 06:05:19 ? 0:10 oracleoss (DESCRIPTION=(LOCAL=NO)(SDU=5844))
oracle 7649 1 0 10:11:28 ? 0:00 oracleoss (DESCRIPTION=(LOCAL=NO)(SDU=5844))
oracle 7654 1 0 10:11:28 ? 0:00 oracleoss (DESCRIPTION=(LOCAL=NO)(SDU=5844))
oracle 22712 1 0 Jun 4 ? 0:00 oracleoss (DESCRIPTION=(LOCAL=NO)(SDU=5844))
oracle 22820 1 0 Jun 4 ? 0:00 oracleoss (DESCRIPTION=(LOCAL=NO)(SDU=5844))
oracle 22824 1 0 Jun 4 ? 12:45 oracleoss (DESCRIPTION=(LOCAL=NO)(SDU=5844))

<< >> 5 Einträge, 1 Seite



View all threads created 2008-07-05 12:37.