Package org.springframework.jdbc.support

Examples of org.springframework.jdbc.support.SQLStateSQLExceptionTranslator


    ctrlStatement.replay();

    JdbcTemplate template = new JdbcTemplate();
    template.setDataSource(mockDataSource);
    // Set custom exception translator
    template.setExceptionTranslator(new SQLStateSQLExceptionTranslator());
    template.afterPropertiesSet();
    try {
      template.query(sql, new RowCallbackHandler() {
        public void processRow(ResultSet rs)
          throws SQLException {
View Full Code Here


    sessionControl.replay();
    uowControl.replay();

    TopLinkTransactionManager tm = new TopLinkTransactionManager();
    tm.setJdbcExceptionTranslator(new SQLStateSQLExceptionTranslator());
    tm.setSessionFactory(sf);
    TransactionTemplate tt = new TransactionTemplate(tm);
    tt.setIsolationLevel(TransactionDefinition.ISOLATION_SERIALIZABLE);
    tt.setTimeout(10);
    assertTrue("Hasn't thread session", !TransactionSynchronizationManager.hasResource(sf));
View Full Code Here

    sessionControl.replay();
    uowControl.replay();

    TopLinkTransactionManager tm = new TopLinkTransactionManager();
    tm.setSessionFactory(sf);
    tm.setJdbcExceptionTranslator(new SQLStateSQLExceptionTranslator());
    TransactionTemplate tt = new TransactionTemplate(tm);
    tt.setIsolationLevel(TransactionDefinition.ISOLATION_SERIALIZABLE);
    tt.setTimeout(10);
    assertTrue("Hasn't thread session", !TransactionSynchronizationManager.hasResource(sf));
    assertTrue("JTA synchronizations not active", !TransactionSynchronizationManager.isSynchronizationActive());
View Full Code Here

    sessionControl.replay();

    TopLinkTransactionManager tm = new TopLinkTransactionManager();
    tm.setSessionFactory(sf);
    tm.setLazyDatabaseTransaction(true);
    tm.setJdbcExceptionTranslator(new SQLStateSQLExceptionTranslator());
    TransactionTemplate tt = new TransactionTemplate(tm);
    tt.setIsolationLevel(TransactionDefinition.ISOLATION_SERIALIZABLE);
    tt.setTimeout(10);
    assertTrue("Hasn't thread session", !TransactionSynchronizationManager.hasResource(sf));
    assertTrue("JTA synchronizations not active", !TransactionSynchronizationManager.isSynchronizationActive());
View Full Code Here

    };
    lsfb.afterPropertiesSet();
    final SessionFactory sfProxy = lsfb.getObject();

    HibernateTransactionManager tm = new HibernateTransactionManager();
    tm.setJdbcExceptionTranslator(new SQLStateSQLExceptionTranslator());
    tm.setSessionFactory(sfProxy);
    tm.setDataSource(ds);
    TransactionTemplate tt = new TransactionTemplate(tm);
    tt.setIsolationLevel(TransactionDefinition.ISOLATION_SERIALIZABLE);
    tt.setTimeout(10);
View Full Code Here

    };
    lsfb.afterPropertiesSet();
    final SessionFactory sfProxy = lsfb.getObject();

    HibernateTransactionManager tm = new HibernateTransactionManager();
    tm.setJdbcExceptionTranslator(new SQLStateSQLExceptionTranslator());
    tm.setSessionFactory(sfProxy);
    tm.setDataSource(ds);
    tm.setEarlyFlushBeforeCommit(true);
    TransactionTemplate tt = new TransactionTemplate(tm);
    tt.setIsolationLevel(TransactionDefinition.ISOLATION_SERIALIZABLE);
View Full Code Here

    given(session.createQuery("some query string")).willReturn(query);
    given(query.list()).willReturn(list);
    given(session.isConnected()).willReturn(true);

    HibernateTransactionManager tm = new HibernateTransactionManager();
    tm.setJdbcExceptionTranslator(new SQLStateSQLExceptionTranslator());
    tm.setNestedTransactionAllowed(true);
    tm.setSessionFactory(sf);
    tm.setDataSource(ds);
    final TransactionTemplate tt = new TransactionTemplate(tm);
    tt.setPropagationBehavior(TransactionDefinition.PROPAGATION_NESTED);
View Full Code Here

    }
    TestJdbcTemplate t = new TestJdbcTemplate();
    t.setDataSource(dataSource);
    // Will fail without the following, because we're not able to get a connection
    // from the DataSource here if we need to to create an ExceptionTranslator
    t.setExceptionTranslator(new SQLStateSQLExceptionTranslator());
    StoredProcedureConfiguredViaJdbcTemplate sp = new StoredProcedureConfiguredViaJdbcTemplate(t);

    assertEquals(sp.execute(11), 5);
    assertEquals(1, t.calls);
View Full Code Here

    given(resultSet.next()).willReturn(true, true, false);
    given(resultSet.getString(1)).willReturn("tb1", "tb2");
    given(resultSet.getInt(2)).willReturn(1, 2);
    template = new JdbcTemplate();
    template.setDataSource(new SingleConnectionDataSource(connection, false));
    template.setExceptionTranslator(new SQLStateSQLExceptionTranslator());
    template.afterPropertiesSet();
  }
View Full Code Here

  public static SQLExceptionTranslator newJdbcExceptionTranslator(SessionFactory sessionFactory) {
    DataSource ds = getDataSource(sessionFactory);
    if (ds != null) {
      return new SQLErrorCodeSQLExceptionTranslator(ds);
    }
    return new SQLStateSQLExceptionTranslator();
  }
View Full Code Here

TOP

Related Classes of org.springframework.jdbc.support.SQLStateSQLExceptionTranslator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.