Example usage for java.sql SQLException printStackTrace

List of usage examples for java.sql SQLException printStackTrace

Introduction

In this page you can find the example usage for java.sql SQLException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:io.moquette.spi.impl.security.DBAuthenticator.java

@Override
public synchronized boolean checkValid(String clientId, String username, byte[] password) {
    // Check Username / Password in DB using sqlQuery
    if (username == null || password == null) {
        LOG.info("username or password was null");
        return false;
    }/*from   ww w .  ja v  a  2 s  .  com*/
    ResultSet r = null;
    try {
        this.preparedStatement.setString(1, username);
        r = this.preparedStatement.executeQuery();
        if (r.next()) {
            final String foundPwq = r.getString(1);
            messageDigest.update(password);
            byte[] digest = messageDigest.digest();
            String encodedPasswd = new String(Hex.encodeHex(digest));
            return foundPwq.equals(encodedPasswd);
        }
        r.close();
    } catch (SQLException e) {
        e.printStackTrace();
    }
    return false;
}

From source file:fastUpload.util.MyBatisConfig.java

@Bean
public DataSource druidDataSource(@Value("${spring.datasource.driver-class-name}") String driver,
        @Value("${spring.datasource.url}") String url, @Value("${spring.datasource.username}") String username,
        @Value("${spring.datasource.password}") String password) {
    DruidDataSource druidDataSource = new DruidDataSource();
    druidDataSource.setDriverClassName(driver);
    druidDataSource.setUrl(url);//  ww w .  ja  va 2s .c  o m
    druidDataSource.setUsername(username);
    druidDataSource.setPassword(password);
    try {
        druidDataSource.setFilters("stat, wall");
    } catch (SQLException e) {
        e.printStackTrace();
    }
    return druidDataSource;
}

From source file:test.other.T_Dao.java

public void clean() {
    try {/* w  w  w .j  a va2s  .c  o m*/
        conn.close();

    } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:controladores.PeliculasController.java

private Connection getConnection(ServletContext servlet) {
    if (this.conexion == null) {
        DriverManagerDataSource dataSource;
        dataSource = (DriverManagerDataSource) this.getBean("dataSource", servlet);
        try {//www  . j  a  v  a 2 s  . co m
            this.conexion = dataSource.getConnection();
        } catch (SQLException ex) {
            ex.printStackTrace();
        }
    }
    return this.conexion;
}

From source file:com.its.web.services.LicensesTypesService.java

public List<LicenseType> readAll() {

    try {/*  ww w .  j  a  v  a2 s  .  co m*/
        return database.getLicenseTypeDao().queryForAll();
    } catch (SQLException e) {
        e.printStackTrace();
        return null;
    }
}

From source file:com.tasktop.c2c.server.configuration.service.DatabaseMetricCollector.java

@Override
public void collect(ProjectServiceStatus status) {
    String databaseName = databaseNamingStrategy.getCurrentTenantDatabaseName();
    if (uppercaseDatbaseName) {
        databaseName = databaseName.toUpperCase();
    }/*from   w  ww .j  a  va  2 s .c  om*/
    String query = sqlSizeQuery.replace(DATABSE_NAME_VAR, databaseName);
    LOG.debug(String.format("Collecting database metrics with query: [%s]", query));
    Connection c = null;
    ResultSet resultSet = null;
    try {
        c = dataSource.getConnection();
        resultSet = c.createStatement().executeQuery(query);
        if (resultSet.next()) {
            int totalByteSize = resultSet.getInt(1);
            status.setServiceState(ServiceState.RUNNING);
            status.getMetrics().put(ProjectServiceStatus.DISK_USAGE_METRICS_KEY, totalByteSize + "");
            status.getMetrics().put(ProjectServiceStatus.DISK_USAGE_HR_METRICS_KEY,
                    FileUtils.byteCountToDisplaySize(totalByteSize));
        }
    } catch (SQLException e) {
        e.printStackTrace();
        status.setServiceState(ServiceState.UNAVAILABLE);
    } finally {
        JdbcUtils.closeResultSet(resultSet);
        if (c != null) {
            try {
                c.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }

}

From source file:com.its.web.services.LicensesTypesService.java

public boolean remove(Long id) {

    try {/*from  www  . j  av a 2 s .c o  m*/
        database.getLicenseTypeDao().deleteIds(Arrays.asList(id));
        return true;
    } catch (SQLException e) {
        e.printStackTrace();
        return false;
    }
}

From source file:com.jp.systemdirector.projectzero.zab01.ap.logicbean.SZAB0111SelectLogicBean.java

@Override
public boolean checkUserInfo(ContextData context, SZAB0111SelectInputData inputData) {

    if (context != null) {
        SZAB0111SelectDTO zDto = new SZAB0111SelectDTO();

        zDto.setUsername(context.getUsername());
        zDto.setPassword(context.getPassword());

        // /*from w w  w.  j a v  a  2 s .c  o  m*/
        try {

            return dao.checkUserinfo(zDto);

        } catch (SQLException e) {

            e.printStackTrace();
            throw new RuntimeException(e);
        }
    }

    return false;
}

From source file:com.fufang.testcase.his.GetMaterialContents.java

@AfterTest
public void deleteSql() throws SQLException {

    SqlUtils c = new SqlUtils();
    Connection Conn = c.mySqlConnection(dbUrl, dbUserName, dbPassword);

    String sql = "DELETE FROM HISFC.t_community_contents WHERE communityId = '200301';";
    try {//from   w  w  w .  ja  v  a 2 s  . c  om
        PreparedStatement pstmt = Conn.prepareStatement(sql);
        pstmt.executeUpdate();
        sql = "DELETE FROM HISFC.t_contents_item WHERE contentsItemId in ('031bbb2f-bda6-4c29-8e8a-c34e3cdca46d','03281538-cfc7-4917-a73f-e4cfe2dd9da6')";
        pstmt.executeUpdate(sql);
    } catch (SQLException e) {
        e.printStackTrace();
    } finally {
        try {
            if (Con != null)
                Con.close();
        } catch (SQLException se) {
            se.printStackTrace();
        }
    }
}

From source file:com.its.web.services.LicensesTypesService.java

public List<LicenseType> findByProduct(Long productId) {

    Map<String, Object> fieldValues = new HashMap<String, Object>();
    fieldValues.put("product_id", productId);

    try {//from w ww . j a  va2s  .co  m
        return database.getLicenseTypeDao().queryForFieldValues(fieldValues);
    } catch (SQLException e) {
        e.printStackTrace();
        return null;
    }
}