Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
midPoint
ConnIdDBBundle
Commits
64e834f2
Commit
64e834f2
authored
Jul 31, 2018
by
Ing. František DVOŘÁK
Browse files
Reconnect locally
parent
ed1c58f6
Changes
1
Hide whitespace changes
Inline
Side-by-side
scriptedsql/src/main/java/net/tirasa/connid/bundles/db/scriptedsql/ScriptedSQLConnection.java
View file @
64e834f2
...
...
@@ -106,14 +106,21 @@ public class ScriptedSQLConnection {
/**
* If internal connection is not usable, throw IllegalStateException
*/
public
void
test
()
{
synchronized
public
void
test
()
{
try
{
if
(
null
==
getSqlConnection
())
throw
new
ConnectionBrokenException
(
"JDBC connection is broken (connect failed)"
);
if
(
sqlConn
.
isClosed
())
throw
new
ConnectionBrokenException
(
"JDBC connection is broken (closed)"
);
if
(!
sqlConn
.
isValid
(
_configuration
.
getValidConnectionTimeout
()))
throw
new
ConnectionBrokenException
(
"JDBC connection is broken (not valid)"
);
// dirty hack - try to reconnect here
for
(
int
attempt
=
1
;
attempt
<=
5
;
attempt
++)
{
if
(
null
==
getSqlConnection
())
throw
new
ConnectionBrokenException
(
"JDBC connection is broken - connect failed"
);
if
(
sqlConn
.
isClosed
())
throw
new
ConnectionBrokenException
(
"JDBC connection is broken - closed"
);
if
(
sqlConn
.
isValid
(
_configuration
.
getValidConnectionTimeout
()))
return
;
LOG
.
error
(
"JDBC connection is broken - closed, attempt {0}"
,
attempt
);
SQLUtil
.
closeQuietly
(
sqlConn
);
sqlConn
=
null
;
}
throw
new
ConnectionBrokenException
(
"JDBC connection is broken - not vali)"
);
}
catch
(
SQLException
e
)
{
throw
ConnectionBrokenException
.
wrap
(
e
);
}
...
...
@@ -124,7 +131,7 @@ public class ScriptedSQLConnection {
*
* @return the connection
*/
public
Connection
getSqlConnection
()
{
synchronized
public
Connection
getSqlConnection
()
{
if
(
sqlConn
==
null
)
{
sqlConn
=
connect
(
_configuration
);
}
...
...
@@ -136,7 +143,7 @@ public class ScriptedSQLConnection {
*
* @param connection
*/
public
void
setSqlConnection
(
Connection
connection
)
{
synchronized
public
void
setSqlConnection
(
Connection
connection
)
{
this
.
sqlConn
=
connection
;
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment