Search code examples
javaoracle11gdatasourceoracle-xe

Interpret JDBC connection


I want to understand the basics of connection to Data Sources. Using Weblogic, if I want to connect to a DataSource, how do I interpret the URL;

jdbc:oracle:thin:@localhost:1521:XE

Also when we specify Username/Password, is that for the entire database?

I am using Oracle 11g XE.

Like what part represents what in this URL?


Solution

  • Whenever you are communicating over the network, you need following three basic things

    1. Protocol
    2. Host
    3. Resource

    Typical example would be

    http://docs.oracle.com/index.html

    Where http - protocol

    docs.oracle.com - host

    index.html the resource

    Similarly other example would be

    ftp://public.ftp-servers.example.com/mydirectory/myfile.txt

    So in general, a resource can be represented over the network as follows

    [PROTOCOL]:[HOST][RESOURCES]

    Extending the same to the JDBC URL you have mentioned

    jdbc:oracle:thin:@localhost:1521:XE

    jdbc:oracle:thin - specifies protocol which in turn indicate which driver is to be used. So every driver has its own protocol to communicate with database server.

    localhost:1521 - is Host

    XE- is the resource which is to be accessed.