Category Archives: Database

Differentiate services and sid in connection string


This might be a basic information for some experts out there but I felt its worth mentioning it here

how will u differentiate between services and the SID to connect to Oracle using JDBC in the connection string

for SID: it goes like
jdbc:oracle:thin:@localhost:1521:XE

for Services you specify like
jdbc:oracle:thin:@localhost:1521/XE

 Class.forName("oracle.jdbc.driver.OracleDriver");
 conn =
 DriverManager.getConnection(jdbc:oracle:thin:@localhost:1521/XE,system,tiger);
 Statement stmt = conn.createStatement();
 ResultSet rset = stmt.executeQuery(query);

Commands used to install XE for LINUX


Download the file from here

go to the installation folder of the rpm file

login as a root

root# rpm -ivh oracle-xe-univ-10.2.0.1-1.0.i386.rpm

to remove the previous installation use

root# rpm -e oracle-xe-univ-10.2.0.1-1.0.i386

root# /etc/init.d/oracle-xe configure
------------------------------------------------------------------------------

[root@indl144224 Desktop]# rpm -ivh oracle-xe-univ-10.2.0.1-1.0.i386.rpm

Preparing...                ########################################### [100%]

1:oracle-xe-univ         ########################################### [100%]

Executing Post-install steps...

You must run '/etc/init.d/oracle-xe configure' as the root user to

configure the database.

[root@indl144224 Desktop]# /etc/init.d/oracle-xe configure

------------------------------------------------------------------------------

user is prompted to configure http port, listener port, and the password for SYs and SYSTEM user

[its better to change to avoid any error in the future]

Oracle Database 10g Express Edition Configuration

-------------------------------------------------

This will configure on-boot properties of Oracle Database 10g Express

Edition.  The following questions will determine whether the database should

be starting upon system boot, the ports it will use, and the passwords that

will be used for database accounts.  Press <Enter> to accept the defaults.

Ctrl-C will abort.

Specify the HTTP port that will be used for Oracle Application Express [8080]:8081

Specify a port that will be used for the database listener [1521]:1522

Specify a password to be used for database accounts.  Note that the same

password will be used for SYS and SYSTEM.  Oracle recommends the use of

different passwords for each database account.  This can be done after

initial configuration:

Confirm the password:

Do you want Oracle Database 10g Express Edition to be started on boot (y/n) [y]:n

Starting Oracle Net Listener...Done

Configuring Database...Done

Starting Oracle Database 10g Express Edition Instance...Done

Installation Completed Successfully.

To access the Database Home Page go to "http://127.0.0.1:8081/apex"

------------------------------------------------------------------------------

export $ORACLE_HOME and $ORACLE_SID

------------------------------------------------------------------------------

[root@indl144224 Desktop]# export ORACLE_HOME=/usr/lib/oracle/xe/

app/     oradata/

[root@indl144224 Desktop]# export ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server

[root@indl144224 Desktop]# export ORACLE_SID=XE

[root@indl144224 Desktop]# cd /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/

------------------------------------------------------------------------------

Check the tns lsitener status

------------------------------------------------------------------------------

[root@indl144224 bin]# ./lsnrctl

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 30-AUG-2010 17:53:57

Copyright (c) 1991, 2005, Oracle.  All rights reserved.

Welcome to LSNRCTL, type "help" for information.

LSNRCTL> status

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC_FOR_XE)))

STATUS of the LISTENER

------------------------

Alias                     LISTENER

Version                   TNSLSNR for Linux: Version 10.2.0.1.0 - Production

Start Date                30-AUG-2010 17:40:21

Uptime                    0 days 0 hr. 13 min. 39 sec

Trace Level               off

Security                  ON: Local OS Authentication

SNMP                      OFF

Default Service           XE

Listener Parameter File   /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/network/admin/listener.ora

Listener Log File         /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/network/log/listener.log

Listening Endpoints Summary...

(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC_FOR_XE)))

(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=indl144224.idc.oracle.com)(PORT=1522)))

(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=8081))(Presentation=HTTP)(Session=RAW))

Services Summary...

Service "PLSExtProc" has 1 instance(s).

Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...

Service "XE" has 1 instance(s).

Instance "XE", status READY, has 1 handler(s) for this service...

Service "XEXDB" has 1 instance(s).

Instance "XE", status READY, has 1 handler(s) for this service...

Service "XE_XPT" has 1 instance(s).

Instance "XE", status READY, has 1 handler(s) for this service...

The command completed successfully

LSNRCTL> exit

Database answers


Found this useful link for all your db design related queries

http://www.databaseanswers.org/data_models/index.htm