java.sql.SQLNonTransientConnectionException Java Examples
The following examples show how to use
java.sql.SQLNonTransientConnectionException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SQLNonTransientConnectionExceptionTests.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * Validate that the ordering of the returned Exceptions is correct * using traditional while loop */ @Test public void test12() { SQLNonTransientConnectionException ex = new SQLNonTransientConnectionException("Exception 1", t1); SQLNonTransientConnectionException ex1 = new SQLNonTransientConnectionException("Exception 2"); SQLNonTransientConnectionException ex2 = new SQLNonTransientConnectionException("Exception 3", t2); ex.setNextException(ex1); ex.setNextException(ex2); int num = 0; SQLException sqe = ex; while (sqe != null) { assertTrue(msgs[num++].equals(sqe.getMessage())); Throwable c = sqe.getCause(); while (c != null) { assertTrue(msgs[num++].equals(c.getMessage())); c = c.getCause(); } sqe = sqe.getNextException(); } }
Example #2
Source File: SQLNonTransientConnectionExceptionTests.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Validate that the ordering of the returned Exceptions is correct * using traditional while loop */ @Test public void test12() { SQLNonTransientConnectionException ex = new SQLNonTransientConnectionException("Exception 1", t1); SQLNonTransientConnectionException ex1 = new SQLNonTransientConnectionException("Exception 2"); SQLNonTransientConnectionException ex2 = new SQLNonTransientConnectionException("Exception 3", t2); ex.setNextException(ex1); ex.setNextException(ex2); int num = 0; SQLException sqe = ex; while (sqe != null) { assertTrue(msgs[num++].equals(sqe.getMessage())); Throwable c = sqe.getCause(); while (c != null) { assertTrue(msgs[num++].equals(c.getMessage())); c = c.getCause(); } sqe = sqe.getNextException(); } }
Example #3
Source File: SQLNonTransientConnectionExceptionTests.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Validate that the ordering of the returned Exceptions is correct * using for-each loop */ @Test public void test11() { SQLNonTransientConnectionException ex = new SQLNonTransientConnectionException("Exception 1", t1); SQLNonTransientConnectionException ex1 = new SQLNonTransientConnectionException("Exception 2"); SQLNonTransientConnectionException ex2 = new SQLNonTransientConnectionException("Exception 3", t2); ex.setNextException(ex1); ex.setNextException(ex2); int num = 0; for (Throwable e : ex) { assertTrue(msgs[num++].equals(e.getMessage())); } }
Example #4
Source File: SQLNonTransientConnectionExceptionTests.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * Validate that the ordering of the returned Exceptions is correct * using for-each loop */ @Test public void test11() { SQLNonTransientConnectionException ex = new SQLNonTransientConnectionException("Exception 1", t1); SQLNonTransientConnectionException ex1 = new SQLNonTransientConnectionException("Exception 2"); SQLNonTransientConnectionException ex2 = new SQLNonTransientConnectionException("Exception 3", t2); ex.setNextException(ex1); ex.setNextException(ex2); int num = 0; for (Throwable e : ex) { assertTrue(msgs[num++].equals(e.getMessage())); } }
Example #5
Source File: TransactionTest.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
public void Debug_tests_43222() throws SQLException { final Connection conn = getConnection(); final Statement stmt = conn.createStatement(); conn.setTransactionIsolation(getIsolationLevel()); stmt.execute("create table warehouse ( w_id integer not null," + " w_ytd decimal(12,2)," + " w_tax decimal(4,4)," + " w_name varchar(10)) replicate"+getSuffix()); stmt.execute("alter table warehouse add constraint pk_warehouse " + "primary key (w_id)"); stmt.execute("insert into warehouse values(1, 0.0, 0.0, 'name1'), " + "(2, 0.2, 0.0, 'name2')"); conn.commit(); int i = stmt.executeUpdate("UPDATE warehouse SET w_ytd = w_ytd + 4998.73 " + "WHERE w_id = 1"); System.out.println(i); SQLNonTransientConnectionException ex = new SQLNonTransientConnectionException(); System.out.println("ex.getSQLState returned: " + ex.getSQLState()); }
Example #6
Source File: SQLNonTransientConnectionExceptionTests.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
/** * Validate that the ordering of the returned Exceptions is correct * using for-each loop */ @Test public void test11() { SQLNonTransientConnectionException ex = new SQLNonTransientConnectionException("Exception 1", t1); SQLNonTransientConnectionException ex1 = new SQLNonTransientConnectionException("Exception 2"); SQLNonTransientConnectionException ex2 = new SQLNonTransientConnectionException("Exception 3", t2); ex.setNextException(ex1); ex.setNextException(ex2); int num = 0; for (Throwable e : ex) { assertTrue(msgs[num++].equals(e.getMessage())); } }
Example #7
Source File: BasicFailover.java From mariadb-connector-j with GNU Lesser General Public License v2.1 | 6 votes |
@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 : "") + ((options.useSsl != null) ? "&useSsl=" + options.useSsl : "") + ((options.serverSslCert != null) ? "&serverSslCert=" + options.serverSslCert : "") + "&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()); } }
Example #8
Source File: CassandraDataSource.java From cassandra-jdbc-wrapper with Apache License 2.0 | 6 votes |
public CassandraConnection getConnection(String user, String password) throws SQLException { Properties props = new Properties(); this.user = user; this.password = password; if (this.serverName!=null) props.setProperty(TAG_SERVER_NAME, this.serverName); else throw new SQLNonTransientConnectionException(HOST_REQUIRED); props.setProperty(TAG_PORT_NUMBER, ""+this.portNumber); if (this.databaseName!=null) props.setProperty(TAG_DATABASE_NAME, this.databaseName); if (user!=null) props.setProperty(TAG_USER, user); if (password!=null) props.setProperty(TAG_PASSWORD, password); if (this.version != null) props.setProperty(TAG_CQL_VERSION, version); if (this.consistency != null) props.setProperty(TAG_CONSISTENCY_LEVEL, consistency); String url = PROTOCOL+createSubName(props); return (CassandraConnection) DriverManager.getConnection(url, props); }
Example #9
Source File: SQLNonTransientConnectionExceptionTests.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Validate that the ordering of the returned Exceptions is correct * using traditional while loop */ @Test public void test12() { SQLNonTransientConnectionException ex = new SQLNonTransientConnectionException("Exception 1", t1); SQLNonTransientConnectionException ex1 = new SQLNonTransientConnectionException("Exception 2"); SQLNonTransientConnectionException ex2 = new SQLNonTransientConnectionException("Exception 3", t2); ex.setNextException(ex1); ex.setNextException(ex2); int num = 0; SQLException sqe = ex; while (sqe != null) { assertTrue(msgs[num++].equals(sqe.getMessage())); Throwable c = sqe.getCause(); while (c != null) { assertTrue(msgs[num++].equals(c.getMessage())); c = c.getCause(); } sqe = sqe.getNextException(); } }
Example #10
Source File: SQLNonTransientConnectionExceptionTests.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
/** * Validate that the ordering of the returned Exceptions is correct * using for-each loop */ @Test public void test11() { SQLNonTransientConnectionException ex = new SQLNonTransientConnectionException("Exception 1", t1); SQLNonTransientConnectionException ex1 = new SQLNonTransientConnectionException("Exception 2"); SQLNonTransientConnectionException ex2 = new SQLNonTransientConnectionException("Exception 3", t2); ex.setNextException(ex1); ex.setNextException(ex2); int num = 0; for (Throwable e : ex) { assertTrue(msgs[num++].equals(e.getMessage())); } }
Example #11
Source File: ShtoPunetor.java From Automekanik with GNU General Public License v3.0 | 6 votes |
private void rregullo(int id){ try { if (!user.getText().isEmpty() && !pw.getText().isEmpty()) { String sql = "update Admin set emri = '" + user.getText() + "', fjalekalimi = '" + pw.getText() + "' where id = " + id; System.out.println("ID: " + id); Connection conn = DriverManager.getConnection(CON_STR, "test", "test"); Statement stmt = conn.createStatement(); stmt.execute(sql); conn.close(); new Mesazhi("Sukses", "", "Te dhenat u ruajten me sukses. Ju lutem restartoni programin."); stage.close(); } else new Mesazhi("Gabim", "", "Fushat duhet te plotesohen para se te vazhdoni"); }catch (SQLNonTransientConnectionException fu){} catch (NullPointerException npe){new Mesazhi("Info", "Gabim", "Fusha qmimi duhet te permbaj vetem numra.");} catch (Exception ex){ex.printStackTrace();} }
Example #12
Source File: TransactionTest.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
public void Debug_tests_43222() throws SQLException { final Connection conn = getConnection(); final Statement stmt = conn.createStatement(); conn.setTransactionIsolation(getIsolationLevel()); stmt.execute("create table warehouse ( w_id integer not null," + " w_ytd decimal(12,2)," + " w_tax decimal(4,4)," + " w_name varchar(10)) replicate"+getSuffix()); stmt.execute("alter table warehouse add constraint pk_warehouse " + "primary key (w_id)"); stmt.execute("insert into warehouse values(1, 0.0, 0.0, 'name1'), " + "(2, 0.2, 0.0, 'name2')"); conn.commit(); int i = stmt.executeUpdate("UPDATE warehouse SET w_ytd = w_ytd + 4998.73 " + "WHERE w_id = 1"); System.out.println(i); SQLNonTransientConnectionException ex = new SQLNonTransientConnectionException(); System.out.println("ex.getSQLState returned: " + ex.getSQLState()); }
Example #13
Source File: SQLNonTransientConnectionExceptionTests.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Create SQLNonTransientConnectionException with message, SQLState, errorCode, and Throwable */ @Test public void test5() { SQLNonTransientConnectionException ex = new SQLNonTransientConnectionException(reason, state, errorCode, t); assertTrue(ex.getMessage().equals(reason) && ex.getSQLState().equals(state) && cause.equals(ex.getCause().toString()) && ex.getErrorCode() == errorCode); }
Example #14
Source File: SQLNonTransientConnectionExceptionTests.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Create SQLNonTransientConnectionException with message, SQLState, and Throwable */ @Test public void test6() { SQLNonTransientConnectionException ex = new SQLNonTransientConnectionException(reason, state, t); assertTrue(ex.getMessage().equals(reason) && ex.getSQLState().equals(state) && cause.equals(ex.getCause().toString()) && ex.getErrorCode() == 0); }
Example #15
Source File: ShtoKonsumator.java From Automekanik with GNU General Public License v3.0 | 5 votes |
private void shto(int id, ShikoKonsumatoret sk){ try { if (!txtEmri.getText().isEmpty() && !txtVendbanimi.getText().isEmpty() && !txtMakina.getText().isEmpty() && !txtMbiemri.getText().isEmpty()){ String em = txtEmri.getText().substring(0, 1).toUpperCase() + txtEmri.getText().substring(1, txtEmri.getText().length()).toLowerCase(); String mb = txtMbiemri.getText().substring(0, 1).toUpperCase() + txtMbiemri.getText().substring(1, txtMbiemri.getText().length()).toLowerCase(); String sql = "update Konsumatori set emri = '" + em + "', mbiemri = '" + mb + "'," + " komuna = '" + txtVendbanimi.getText() + "', makina = '" + txtMakina.getText() + "', pershkrimi = '" + txtDesc.getText() + "' where id = " + id; Connection conn = DriverManager.getConnection(CON_STR, "test", "test"); Statement stmt = conn.createStatement(); stmt.execute(sql); new Mesazhi("Sukses", "Te dhenat u ruajten", "Te dhenat per konsumatorin " + txtEmri.getText() + " " + txtMbiemri.getText() + ",\n u azhurnuan me sukses"); conn.close(); new Thread(new Runnable() { @Override public void run() { sk.mbushTabelen(); } }).start(); stage.close(); }else new Mesazhi("Info", "", "Fushat duhet te plotesohen per te vazhduar."); }catch (SQLNonTransientConnectionException fu){} catch (Exception ex){ ex.printStackTrace(); } }
Example #16
Source File: SQLNonTransientConnectionExceptionTests.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Create SQLNonTransientConnectionException with message, and Throwable */ @Test public void test7() { SQLNonTransientConnectionException ex = new SQLNonTransientConnectionException(reason, t); assertTrue(ex.getMessage().equals(reason) && ex.getSQLState() == null && cause.equals(ex.getCause().toString()) && ex.getErrorCode() == 0); }
Example #17
Source File: SQLNonTransientConnectionExceptionTests.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Create SQLNonTransientConnectionException with null Throwable */ @Test public void test8() { SQLNonTransientConnectionException ex = new SQLNonTransientConnectionException((Throwable)null); assertTrue(ex.getMessage() == null && ex.getSQLState() == null && ex.getCause() == null && ex.getErrorCode() == 0); }
Example #18
Source File: SQLNonTransientConnectionExceptionTests.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Create SQLNonTransientConnectionException with no-arg constructor */ @Test public void test1() { SQLNonTransientConnectionException ex = new SQLNonTransientConnectionException(); assertTrue(ex.getMessage() == null && ex.getSQLState() == null && ex.getCause() == null && ex.getErrorCode() == 0); }
Example #19
Source File: SQLNonTransientConnectionExceptionTests.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Create SQLNonTransientConnectionException with message */ @Test public void test2() { SQLNonTransientConnectionException ex = new SQLNonTransientConnectionException(reason); assertTrue(ex.getMessage().equals(reason) && ex.getSQLState() == null && ex.getCause() == null && ex.getErrorCode() == 0); }
Example #20
Source File: SQLNonTransientConnectionExceptionTests.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Create SQLNonTransientConnectionException with message, SQLState, errorCode, and Throwable */ @Test public void test5() { SQLNonTransientConnectionException ex = new SQLNonTransientConnectionException(reason, state, errorCode, t); assertTrue(ex.getMessage().equals(reason) && ex.getSQLState().equals(state) && cause.equals(ex.getCause().toString()) && ex.getErrorCode() == errorCode); }
Example #21
Source File: SQLNonTransientConnectionExceptionTests.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Create SQLNonTransientConnectionException with message, SQLState, and error code */ @Test public void test4() { SQLNonTransientConnectionException ex = new SQLNonTransientConnectionException(reason, state, errorCode); assertTrue(ex.getMessage().equals(reason) && ex.getSQLState().equals(state) && ex.getCause() == null && ex.getErrorCode() == errorCode); }
Example #22
Source File: SQLNonTransientConnectionExceptionTests.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Create SQLNonTransientConnectionException with message, and SQLState */ @Test public void test3() { SQLNonTransientConnectionException ex = new SQLNonTransientConnectionException(reason, state); assertTrue(ex.getMessage().equals(reason) && ex.getSQLState().equals(state) && ex.getCause() == null && ex.getErrorCode() == 0); }
Example #23
Source File: SQLNonTransientConnectionExceptionTests.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Create SQLNonTransientConnectionException with message */ @Test public void test2() { SQLNonTransientConnectionException ex = new SQLNonTransientConnectionException(reason); assertTrue(ex.getMessage().equals(reason) && ex.getSQLState() == null && ex.getCause() == null && ex.getErrorCode() == 0); }
Example #24
Source File: SQLNonTransientConnectionExceptionTests.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Create SQLNonTransientConnectionException with no-arg constructor */ @Test public void test1() { SQLNonTransientConnectionException ex = new SQLNonTransientConnectionException(); assertTrue(ex.getMessage() == null && ex.getSQLState() == null && ex.getCause() == null && ex.getErrorCode() == 0); }
Example #25
Source File: SQLNonTransientConnectionExceptionTests.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Create SQLNonTransientConnectionException and setting all objects to null */ @Test public void test() { SQLNonTransientConnectionException e = new SQLNonTransientConnectionException(null, null, errorCode, null); assertTrue(e.getMessage() == null && e.getSQLState() == null && e.getCause() == null && e.getErrorCode() == errorCode); }
Example #26
Source File: TestGenerateTableFetch.java From localization_nifi with Apache License 2.0 | 5 votes |
@AfterClass public static void cleanUpAfterClass() throws Exception { try { DriverManager.getConnection("jdbc:derby:" + DB_LOCATION + ";shutdown=true"); } catch (SQLNonTransientConnectionException e) { // Do nothing, this is what happens at Derby shutdown } // remove previous test database, if any final File dbLocation = new File(DB_LOCATION); try { FileUtils.deleteFile(dbLocation, true); } catch (IOException ioe) { // Do nothing, may not have existed } }
Example #27
Source File: QueryDatabaseTableTest.java From localization_nifi with Apache License 2.0 | 5 votes |
@AfterClass public static void cleanUpAfterClass() throws Exception { try { DriverManager.getConnection("jdbc:derby:" + DB_LOCATION + ";shutdown=true"); } catch (SQLNonTransientConnectionException e) { // Do nothing, this is what happens at Derby shutdown } // remove previous test database, if any final File dbLocation = new File(DB_LOCATION); try { FileUtils.deleteFile(dbLocation, true); } catch (IOException ioe) { // Do nothing, may not have existed } }
Example #28
Source File: SQLNonTransientConnectionExceptionTests.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Create SQLNonTransientConnectionException with message, and Throwable */ @Test public void test7() { SQLNonTransientConnectionException ex = new SQLNonTransientConnectionException(reason, t); assertTrue(ex.getMessage().equals(reason) && ex.getSQLState() == null && cause.equals(ex.getCause().toString()) && ex.getErrorCode() == 0); }
Example #29
Source File: SQLNonTransientConnectionExceptionTests.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Create SQLNonTransientConnectionException with null Throwable */ @Test public void test8() { SQLNonTransientConnectionException ex = new SQLNonTransientConnectionException((Throwable)null); assertTrue(ex.getMessage() == null && ex.getSQLState() == null && ex.getCause() == null && ex.getErrorCode() == 0); }
Example #30
Source File: SectDBSynchronizer.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
protected SqlExceptionHandler checkExceptionType(SQLException sqle) { if (sqle != null) { if (sqle instanceof SQLNonTransientConnectionException) { // will need to connect again return SqlExceptionHandler.REFRESH; } if (sqle instanceof SQLIntegrityConstraintViolationException) { // constraint violations can happen in retries, so default action is to // IGNORE them; when errorFile is provided then it will be logged to // that in XML format in any case return SqlExceptionHandler.IGNORE; } if (sqle instanceof SQLNonTransientException) { // if numErrorTries is defined, then retry some number of times else // ignore after having logged warning since retry is not likely to help return this.numErrorTries > 0 ? SqlExceptionHandler.IGNORE_BREAK_LOOP : SqlExceptionHandler.IGNORE; } if (sqle instanceof SQLTransientException) { // skip the remaining batch and retry whole batch again return SqlExceptionHandler.IGNORE_BREAK_LOOP; } if (sqle instanceof BatchUpdateException) { return checkExceptionType(sqle.getNextException()); } } return null; }