Question

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?

Was it helpful?

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.

OTHER TIPS

Connection string definition

 jdbc:oracle:thin:[USER/PASSWORD]@[HOST][:PORT]:SID

jdbc:oracle:thin specifies Oracle's JDBC Thin driver.

@localhost is the hostname , the DB server machine.

1521 post at which the server runs.

XE may be a oracle service name or a SID, defined in tnsnames.ora file

You can specify the usernam/password also :

jdbc:oracle:thin:[USER/PASSWORD]@//[HOST][:PORT]/SERVICE

I recommend you the JDBC Tutorial and more precisely Java DB Database Connection URLs

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

jdbc: part defines the protocol

oracle:thin part defines the driver

@localhost defines server address (here localhost, can be an IP address or host name)

1521 defines the remote port

XE defines the SID of the database

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

you will have access to what is available to the user you provided, so it depends on the database configuration

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top