| |
 |
December 28, 1997
I prefer to always use a TDatabase component for connecting to Oracle. You don't have to,
since Delphi creates a default instance of TDatabase if you don't create it yourself. But then
you absolutely have to remember to set a few key parameters correctly at runtime, and in my
view it then is better to just create your own instance and set the parameters once.
DO NOT use multible instances of TDatabase for Oracle connections. This has to do with
resources and speed, primarily. You use resources both at the server and the client for
a session. And, depending on the user's privileges, you can really hog a system if
every user creates 5 sessions in your program.
You also need an instance of TSession, but here I always use the default instance created
by Delphi itself. Haven't had any reason yet to manage TSession and multible Tdatabases.
The issue of speed really mostly concerns the time it takes to establish a session over
the network. This has everything to do with how your networks operates, so maybe you ought
to look at this if it takes a long time to connect..
Personally I don't use the BDE aliases much, I prefer to take the default settings from
the driver and just modify what I need. This may no always be optimal since it makes a
program more bound to the current settings. On the other hand you need to make sure that the
correct aliases are defined at all the clients who will be running the program if you use
that approach.
The way to do it is this: Drop a TDatabase component on your form (preferably a datamodule:))
Double-click on it. Now select a driver (Oracle) and press the 'Defaults' button.
This produces a list of the modifiable parameters from the Oracle driver settings. This
sample uses Personal Oracle 7.2:
SERVER NAME=2:
USER NAME=scott
NET PROTOCOL=
OPEN MODE=READ/WRITE
SCHEMA CACHE SIZE=8
LANGDRIVER=DBWINWE0
SQLQRYMODE=SERVER
SQLPASSTHRU MODE=SHARED AUTOCOMMIT
SCHEMA CACHE TIME=-1
MAX ROWS=-1
BATCH COUNT=200
ENABLE SCHEMA CACHE=FALSE
SCHEMA CACHE DIR=
ENABLE BCD=FALSE
ENABLE INTEGERS=FALSE
LIST SYNONYMS=ALL
ROWSET SIZE=20
BLOBS TO CACHE=64
BLOB SIZE=32
PASSWORD=
While developing apps, set the USER NAME and PASSWORD and disable the 'Login prompt'
checkbox. This way you don't have to type login information everytime you need to connect.
ALWAYS check the 'Keep inactive connection' option. Otherwise Delphi closes and reopens
the connection for every query. This will drive you mad in minutes!!
Now type a name for the connection, and you're done.
Note
Some people out there are having problems with setting these parameters at runtime. This
is necessary if you want to have your own login prompt, for instance.
Assuming you named the database component 'DB' and placed it in a
datamodule called 'DMod', You'd do it like this:
with DMod.DB do begin
Params.Values['USER NAME']:='SCOTT';
Params.Values['PASSWORD']:='TIGER';
end;
Just remember to reconnect after the modifications.
Another note
Oracle usernames are stored in uppercase. This means that if you pass the username in
lowercase to Oracle, it will be converted to uppercase. If you have usernames with accented
characters, for example, you might run in to trouble if there's a character set mismatch between
Oracle and the client.
|
|
| Hits/month |
2,500,000+ |
Downloads (Since May 2000) |
7,393,709 |
| Total Files |
6,023 |
| Forum msgs |
7,670 |
| Articles/FAQs |
70+/900+ |
Top Selling Software at Amazon
|