Coder Social home page Coder Social logo

On connection pool problem about ocilib HOT 6 CLOSED

MagicXran avatar MagicXran commented on July 3, 2024
On connection pool problem

from ocilib.

Comments (6)

MagicXran avatar MagicXran commented on July 3, 2024

In order to maximize usage, I will execute multiple sql on the same connection.
Please tell me, is this possible, or are there any better improvement measures? thanks!

 // initialize  ocilib::Pool pool

function (ocilib::Pool pool)
{
  auto conn = pool.getConnection();
  ocilib::Statement stmt(conn);

  if(condition)
   {
     try
						{
					
							stmt.Execute(sql);
							conn.Commit();
						}
						catch (...)
						{
							conn.Rollback();
							std::cerr << "Error in " << EventName << std::endl;
						}
}

// Use the same connection
 try
						{
					
							stmt.Execute(sql2);
							conn.Commit();
						}
						catch (...)
						{
							conn.Rollback();
							std::cerr << "Error in " << EventName << std::endl;
						}
//.....

from ocilib.

vrogier avatar vrogier commented on July 3, 2024

Hi,

As soon the connection object is out of scope (destructor invoked) and if there is no more reference to the underlying handle, the oracle connection is returned to the pool automatically.
Calling connection::Close() does the same ( in fact the destructor calls Close()).

By default, in case of exhausted pool, Pool::GetConnection() is a blocking call until a connection is available (this behaviour can be changed using Pool::SetNoWait()).

Regards,

Vincent

from ocilib.

MagicXran avatar MagicXran commented on July 3, 2024

If Pool::SetNoWait(TRUE), what happens when the connection resources are exhausted? Will a new connection resource be created? Or return empty? Or something else

from ocilib.

vrogier avatar vrogier commented on July 3, 2024

Pool::GetConnection() will raise an exception

from ocilib.

MagicXran avatar MagicXran commented on July 3, 2024

Excuse me, is it possible to establish two ocilib::Pool to connect to different databases respectively? Will there be conflicts?

from ocilib.

vrogier avatar vrogier commented on July 3, 2024

Of course you can use different pools to connect to different databases :)

Vincent

from ocilib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.