-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CONJ-555] failover implementation correction when issue is due to ti…
…meout client side.
- Loading branch information
Showing
5 changed files
with
49 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package org.mariadb.jdbc; | ||
|
||
import org.junit.Test; | ||
|
||
import java.sql.Connection; | ||
import java.sql.DriverManager; | ||
import java.sql.SQLNonTransientConnectionException; | ||
import java.sql.Statement; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
import static org.junit.Assert.fail; | ||
|
||
public class BasicFailover extends BaseTest { | ||
|
||
@Test | ||
public void failoverRetry() throws Throwable { | ||
try (Connection connection = DriverManager.getConnection("jdbc:mariadb:failover//" + ((hostname != null) ? hostname : "localhost") | ||
+ ":" + port + "/" + database + "?user=" + username | ||
+ ((password != null) ? "&password=" + password : "") + "&socketTimeout=1000")) { | ||
try (Statement stmt = connection.createStatement()) { | ||
stmt.execute("SELECT SLEEP(10)"); | ||
fail(); | ||
} catch (SQLNonTransientConnectionException e) { | ||
//normal error : fail to reconnect, since second execution fail too | ||
} | ||
assertTrue(connection.isClosed()); | ||
} | ||
} | ||
|
||
} |