What is Oracle Session? - oracle

I am using Oracle 11g.
I am looking for a good explanation of Oracle Sessions. I googled for this, but strangely, none of the web sites contain any explanation of what oracles sessions are. My specific questions are
1) What are oracle sessions?
2) Does one connection object always relate to one oracle session.?
3) can one oracle session be shared by another connection started by the same user.?

A logical entity in the database instance memory that represents the state of a current user login to a database.
A single connection can have 0, 1, or more sessions established on it.
I can't imagine that it can
http://docs.oracle.com/cd/E28271_01/server.1111/e25789/glossary.htm

Related

find who is connecting to database using db link

currently, we are using oracle 8i and we are working to decommisson it.
I need to find out which all other databases are connecting to our database using db link.
Please note, I am not looking for the connection from our database to others database. I already got that information using all_Db_links.
If you audit connections to the database or look at the listener log, that will tell you the machines that are connecting to the database and the application that is connecting (that information is coming from the client so it could be spoofed but I'm assuming no one is actively trying to hide information from you). That should allow you to determine which connections are coming via database links. That may not tell you which database on the particular server is connecting if there are multiple databases on the same server using the same Oracle Home. But it should narrow it down to a relatively small number of databases that you can manually check.

Oracle FAN with Oracle Data Guard but without using Oracle Grid/ RAC

Is it possible for a JDBC application to receive Fast Application Notification (FAN) from an Oracle Data Guard broker when a SWITCHOVER happens from a primary to a secondary database, so that the application can reconnect without Oracle RAC/ cluster? That is, I have just got a single instance database on the primary site and a similar setup on the secondary site, and I want my Java based application to detect and reconnect in case of FAILOVER/ SWITCHOVER.
Based on what I know about FAN, it depends on Oracle Notification Service, which indirectly means Oracle RAC/ Grid. Is this understanding correct? Oracle Data Guard, by itself, doesn't require either Oracle RAC or Oracle Grid.
If FAN is not available, what are the options for an application to get the connection to the new primary without requiring a restart?
You need either Oracle Grid or Oracle RAC. It cannot be configured with a simple Oracle Data Guard set up with single instance non-RAC databases.
Client failover
There are two things that we need to consider for client failover:
Detecting database failover
Reconnecting with the new primary
Detecting database failover
FAN mainly helps with the first point. Without FAN, the application would have to rely on database connection errors to detect that the database has failed (or no longer the primary database). This could happen in three different ways:
While establishing a new connection, the application would fail to connect with a failed database. If it was a SWITCHOVER, the application will also fail to establish a connection with a standby database with (plain) Oracle Data Guard. For Active Oracle Data Guard, it will fail to open up a connection unless its in read-only mode.
An existing connection which is already closed from the database side would throw an error. The application needs to catch this error and respond accordingly.
If the connection is still valid (for some reason), and the database is no longer available to respond (as it has failed), the application has to rely on TCP/ IP timeouts and OS level handling of sockets. For this, Oracle recommends that you tune the timeouts at the kernel level.
Once you detect connection failure, your application should be capable of creating a new connection to the database. This connection should be established with the new primary, as explained next.
Reconnecting with the new primary
Whether you use FAN or not, you can specify an address list (instead of a single database) in your connection string. This allows you to use a single connection string for multiple databases and can help you with Oracle Data Guard failover scenarios as well. A sample connection string for JDBC with multiple addresses is given below:
jdbc:oracle:thin:<userid>/<pwd>#(DESCRIPTION_LIST=
(LOAD_BALANCE=off)(FAILOVER=on)
(DESCRIPTION=
(CONNECT_TIMEOUT=6)(TRANSPORT_CONNECT_TIMEOUT=3)(RETRY_COUNT=2)
(ADDRESS_LIST=
(LOAD_BALANCE=on)
(ADDRESS=(PROTOCOL=TCP)(HOST=<primary-host-name>)(PORT=<port>))
)
(CONNECT_DATA=(SERVICE_NAME=<dbServiceNameOnPrimary>))
)
(DESCRIPTION=
(CONNECT_TIMEOUT=6)(TRANSPORT_CONNECT_TIMEOUT=3)(RETRY_COUNT=2)
(ADDRESS_LIST=
(LOAD_BALANCE=on)
(ADDRESS=(PROTOCOL=TCP)(HOST=<standby-host-name>)(PORT=<port>))
)
(CONNECT_DATA=(SERVICE_NAME=<dbServiceNameOnStandby>))
))
Source: Client Failover Best Practices for Highly Available Oracle Databases (pdf)

ORACLE Application Express - how to connect to your tables in production

I've been trying for days but cannot find the answer to this. I am using Oracle Application Express (APEX), someone else setup the initial connection to a "Apex" database in oracle, but I am trying to connect to our production database in oracle. I am making web forms and the web forms are connected to the "Apex" database that was setup already, but I need to connect to our production database so we can create reports from the data entered through the web forms. I need the tables to show up in the create page option from the production database, currently its coming from the apex database, please help.
Create Page View with Tables (from apex)
Thank You so much in Advance!
What is the "production database"? Is it really a different database (than the one you're currently connected to), or is it a user in the same database?
if former:
you could create a database link between those two databases and create synonyms for production users' tables in one of schemas your workspace is assigned to.
another option is to install Apex onto the production database, so that you could use current installation as "development" and then deploy the application into the "production-based" Apex
if latter, you might do the same (i.e. create synonyms, just without the database link), or simply assign the production schema to your workspace
You may be interested to read Mike's response to a question with a similar misunderstanding regarding architecture.
https://community.oracle.com/thread/4135843
Once you have your head wrapped around this, you can consider the parsing schema to your application. This schema defines the table access your application has, in the normal way Oracle handles table privileges.
Then it's up to you to define who has access to what pages, using APEX Authorisation Schemes.

glassfish JDBC Connection Pooling and oracle global temporary table same sessionId

Before I start with my question, I would like to clarify that I am java/j2ee developer and have limited understanding of things on oracle side.
I am using glassfish server with JDBC connection Pooling and in back side, oracle database.
Also i am using global temporary table of oracle to execute some work flow.
i am storing session specific data in global temp table.
Now my issue is most of the time i am getting the same sessionId for each connection.
Does that means i can't use glboal temporary table with glassfish JDBC connection Pooling.
Another interesting thing is if i removed connection pooling then i am getting different sessionID for each connection.
Please provide your suggestions.
When using Connection Pooling it's always best to not leave states in the database session when the connection is released into the pool. That's because there is no guarantee that you'll get back the same connection the next time you need one. A global temp table (GTT) is an example of such a state and belongs to one Database session, or to one JDBC connection (there is a 1-1 mapping between DB session and JDBC connection). It won't be visible if you use another JDBC connection.
So if your business logic requires that you use a GTT then you should not release the connection back to the pool until you're dong using this GTT. Note that this goes against the best practices which recommend to release the connection back to the pool as soon as possible. As an alternative you may use a normal table and commit your temporary results into it so that they can be accessed through any other connection.

List of Clients that connected to Oracle Historically

Oracle 10G
Is it possible to get a list of all Client Programs that have connected to my Oracle Database Historically.
I can always get the current list of active sessions using V$SESSION but is there somewhere that historical connection information is recorded? I need this to know who all are using a particular database user for connecting to the database.
You will find some information in the listener.log (executable, osuser)
As far as I know, audit trail is the only way to list connection history. If audit trail isn't enabled you are left with the listener.log and v$session.
Bjarte

Resources