After oracle11g is installed today, a JDBC test program is written and cannot be connected all the time!
Why cannot be found
Later, I read the readme.txt document in the ghost Installation File! This version actually changes the URL access method:
Some useful hints in using the JDBC drivers
-------------------------------------------
Please refer to "JDBC developer's guide and reference" For details
Regarding usage of Oracle's JDBC drivers. This section only offers
Useful hints. These hints are not meant to be exhaustive.
These are a few simple things that you shoshould do in your JDBC program:
1. Import the necessary JDBC classes in your programs that use JDBC.
For example:
Import java. SQL .*;
Import java. Math. *; // if needed
To use oracledatasource, you need to do:
Import oracle. JDBC. Pool. oracledatasource;
2. Create an oracledatasource instance.
Oracledatasource ODS = new oracledatasource ();
3. Set the desired properties if you don't want to use
Default properties. Different connection URLs shocould be
Used for different JDBC drivers.
ODS. setuser ("my_user ");
ODS. setpassword ("my_password ");
For the jdbc oci driver:
To make a bequeath connection, set URL:
ODS. seturl ("JDBC: oracle: OCI :@");
To make a remote connection, set URL:
ODS. seturl ("JDBC: oracle: OCI: @ <database> ");
Where <database> is either a tnsentryname
Or a SQL * Net name-Value Pair defined in tnsnames. ora.
For the JDBC thin driver, or server-side thin DRIVER:
ODS. seturl ("JDBC: oracle: thin: @ <database> ");
Where <database> is either a string of the form
// <Host>: <port>/<SERVICE_NAME>, or a SQL * Net name-value pair,
Or a tnsentryname.
For the JDBC server-side internal DRIVER:
ODS. seturl ("JDBC: oracle: kprb :");
Note that the trailing ':' is necessary. When you use
Server-side internal driver, you always connect to
Database you are executing in. You can also do this:
Connection conn =
New Oracle. JDBC. oracledriver (). defaultconnection ();
4. open a connection to the database with getconnection ()
Methods defined in oracledatasource class.
Connection conn = ODS. getconnection ();
------------------------------------------------------------------------
You still have a good look at the original documentation!
But I still don't understand why it suddenly changes?