Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cta
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dCache
cta
Commits
928b17ab
Commit
928b17ab
authored
8 years ago
by
Steven Murray
Browse files
Options
Downloads
Patches
Plain Diff
Removed get() and operator->() from rdbms::OcciConn
parent
04b5bf09
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
rdbms/OcciConn.cpp
+51
-16
51 additions, 16 deletions
rdbms/OcciConn.cpp
rdbms/OcciConn.hpp
+7
-16
7 additions, 16 deletions
rdbms/OcciConn.hpp
rdbms/OcciStmt.cpp
+5
-7
5 additions, 7 deletions
rdbms/OcciStmt.cpp
rdbms/OcciStmt.hpp
+6
-1
6 additions, 1 deletion
rdbms/OcciStmt.hpp
with
69 additions
and
40 deletions
rdbms/OcciConn.cpp
+
51
−
16
View file @
928b17ab
...
...
@@ -64,32 +64,28 @@ OcciConn::~OcciConn() throw() {
void
OcciConn
::
close
()
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
m_mutex
);
if
(
m_occiConn
!=
nullptr
)
{
if
(
nullptr
!=
m_occiConn
)
{
m_env
->
terminateConnection
(
m_occiConn
);
m_occiConn
=
nullptr
;
}
}
//------------------------------------------------------------------------------
// get
//------------------------------------------------------------------------------
oracle
::
occi
::
Connection
*
OcciConn
::
get
()
const
{
return
m_occiConn
;
}
//------------------------------------------------------------------------------
// operator->()
//------------------------------------------------------------------------------
oracle
::
occi
::
Connection
*
OcciConn
::
operator
->
()
const
{
return
get
();
}
//------------------------------------------------------------------------------
// createStmt
//------------------------------------------------------------------------------
std
::
unique_ptr
<
Stmt
>
OcciConn
::
createStmt
(
const
std
::
string
&
sql
,
Stmt
::
AutocommitMode
autocommitMode
)
{
try
{
return
cta
::
make_unique
<
OcciStmt
>
(
autocommitMode
,
sql
,
*
this
);
std
::
lock_guard
<
std
::
mutex
>
lock
(
m_mutex
);
if
(
nullptr
==
m_occiConn
)
{
throw
exception
::
Exception
(
"Connection is closed"
);
}
oracle
::
occi
::
Statement
*
const
stmt
=
m_occiConn
->
createStatement
(
sql
);
if
(
nullptr
==
stmt
)
{
throw
exception
::
Exception
(
"oracle::occi::createStatement() returned a nullptr pointer"
);
}
return
cta
::
make_unique
<
OcciStmt
>
(
autocommitMode
,
sql
,
*
this
,
stmt
);
}
catch
(
exception
::
Exception
&
ex
)
{
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" failed for SQL statement "
+
sql
+
": "
+
ex
.
getMessage
().
str
());
...
...
@@ -103,7 +99,15 @@ std::unique_ptr<Stmt> OcciConn::createStmt(const std::string &sql, Stmt::Autocom
//------------------------------------------------------------------------------
void
OcciConn
::
commit
()
{
try
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
m_mutex
);
if
(
nullptr
==
m_occiConn
)
{
throw
exception
::
Exception
(
"Connection is closed"
);
}
m_occiConn
->
commit
();
}
catch
(
exception
::
Exception
&
ex
)
{
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" failed: "
+
ex
.
getMessage
().
str
());
}
catch
(
std
::
exception
&
se
)
{
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" failed: "
+
se
.
what
());
}
...
...
@@ -114,7 +118,15 @@ void OcciConn::commit() {
//------------------------------------------------------------------------------
void
OcciConn
::
rollback
()
{
try
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
m_mutex
);
if
(
nullptr
==
m_occiConn
)
{
throw
exception
::
Exception
(
"Connection is closed"
);
}
m_occiConn
->
rollback
();
}
catch
(
exception
::
Exception
&
ex
)
{
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" failed: "
+
ex
.
getMessage
().
str
());
}
catch
(
std
::
exception
&
se
)
{
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" failed: "
+
se
.
what
());
}
...
...
@@ -152,5 +164,28 @@ bool OcciConn::isOpen() const {
return
nullptr
!=
m_occiConn
;
}
//------------------------------------------------------------------------------
// closeStmt
//------------------------------------------------------------------------------
void
OcciConn
::
closeStmt
(
oracle
::
occi
::
Statement
*
const
stmt
)
{
try
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
m_mutex
);
if
(
nullptr
==
m_occiConn
)
{
throw
exception
::
Exception
(
"Connection is closed"
);
}
if
(
nullptr
==
stmt
)
{
throw
exception
::
Exception
(
"stmt is a nullptr"
);
}
m_occiConn
->
terminateStatement
(
stmt
);
}
catch
(
exception
::
Exception
&
ex
)
{
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" failed: "
+
ex
.
getMessage
().
str
());
}
catch
(
std
::
exception
&
se
)
{
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" failed: "
+
se
.
what
());
}
}
}
// namespace rdbms
}
// namespace cta
This diff is collapsed.
Click to expand it.
rdbms/OcciConn.hpp
+
7
−
16
View file @
928b17ab
...
...
@@ -59,22 +59,6 @@ public:
*/
virtual
void
close
()
override
;
/**
* Returns the underlying OCCI connection.
*
* This method will always return a valid pointer.
*
* @return The underlying OCCI connection.
*/
oracle
::
occi
::
Connection
*
get
()
const
;
/**
* An alias for the get() method.
*
* @return The underlying OCCI connection.
*/
oracle
::
occi
::
Connection
*
operator
->
()
const
;
/**
* Creates a prepared statement.
*
...
...
@@ -127,6 +111,13 @@ private:
*/
oracle
::
occi
::
Connection
*
m_occiConn
;
/**
* Closes the specified OCCI statement.
*
* @param stmt The OCCI statement to be closed.
*/
void
closeStmt
(
oracle
::
occi
::
Statement
*
const
stmt
);
};
// class OcciConn
}
// namespace rdbms
...
...
This diff is collapsed.
Click to expand it.
rdbms/OcciStmt.cpp
+
5
−
7
View file @
928b17ab
...
...
@@ -36,15 +36,13 @@ namespace rdbms {
OcciStmt
::
OcciStmt
(
const
AutocommitMode
autocommitMode
,
const
std
::
string
&
sql
,
OcciConn
&
conn
)
:
OcciConn
&
conn
,
oracle
::
occi
::
Statement
*
const
stmt
)
:
Stmt
(
autocommitMode
),
m_sql
(
sql
),
m_paramNameToIdx
(
sql
),
m_conn
(
conn
)
{
m_stmt
=
m_conn
->
createStatement
(
sql
);
if
(
nullptr
==
m_stmt
)
{
throw
exception
::
Exception
(
"oracle::occi::createStatement() returned a nullptr pointer"
);
}
m_conn
(
conn
),
m_stmt
(
stmt
)
{
// m_occiConn and m_stmt have been set and m_stmt is not nullptr so it is safe to
// call close() from now on
...
...
@@ -88,7 +86,7 @@ void OcciStmt::close() {
std
::
lock_guard
<
std
::
mutex
>
lock
(
m_mutex
);
if
(
nullptr
!=
m_stmt
)
{
m_conn
->
terminateStatemen
t
(
m_stmt
);
m_conn
.
closeStm
t
(
m_stmt
);
m_stmt
=
nullptr
;
}
}
catch
(
exception
::
Exception
&
ex
)
{
...
...
This diff is collapsed.
Click to expand it.
rdbms/OcciStmt.hpp
+
6
−
1
View file @
928b17ab
...
...
@@ -53,8 +53,13 @@ public:
* @param autocommitMode The autocommit mode of the statement.
* @param sql The SQL statement.
* @param conn The database connection.
* @param stmt The OCCI statement.
*/
OcciStmt
(
const
AutocommitMode
autocommitMode
,
const
std
::
string
&
sql
,
OcciConn
&
conn
);
OcciStmt
(
const
AutocommitMode
autocommitMode
,
const
std
::
string
&
sql
,
OcciConn
&
conn
,
oracle
::
occi
::
Statement
*
const
stmt
);
/**
* Destructor.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment