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:com.ws.WS_TCS.java

@Path("/GetAccount")
@GET// www  . j a va 2  s.c  o  m
@Produces(MediaType.APPLICATION_JSON)
public List<DS_TCSTCE> GetAccount() {
    List<DS_TCSTCE> output = new ArrayList<DS_TCSTCE>();
    PreparedStatement prepStmt = null;
    try {
        String cSQL = "SELECT TCEEMP FROM TCSTCE WHERE TCELJD = 0 ORDER BY TCEEMP";
        prepStmt = connection.prepareStatement(cSQL);
        ResultSet result = prepStmt.executeQuery();
        if (result.next()) {
            while (result.next()) {
                DS_TCSTCE acc = new DS_TCSTCE();
                acc.setEmp(result.getString(1));
                output.add(acc);
            }
        }
    } catch (SQLException e) {
        prepStmt = null;
        e.printStackTrace();
    }
    return output;
}

From source file:hmp.HMPRunRemover.java

private void deleteRdpSummaryData(ArrayList<Integer> samples) {
    for (int id : samples) {
        String sql = "delete from rdp_summary_data where sample_id = " + id;
        int rows = 0;
        try {/*from   www. java 2 s.co m*/
            rows = conn.createStatement().executeUpdate(sql);
        } catch (SQLException e) {
            System.out.println("ERROR deleteRdpSummaryData:" + sql);
            e.printStackTrace();
            System.exit(0);
        }
        System.out.println("deleted " + rows + " from rdp_summary_data for sample " + id);
    }
}

From source file:com.ws.WS_TCS.java

@Path("/GetLeave")
@GET/*from ww  w . j  a  v a 2  s. com*/
@Produces(MediaType.APPLICATION_JSON)
public List<DS_TCSTCC> GetLeave() {
    List<DS_TCSTCC> output = new ArrayList<DS_TCSTCC>();
    PreparedStatement prepStmt = null;
    try {
        String cSQL = "SELECT TCCTCD, TCCTXT FROM TCSTCC ORDER BY TCCTCD";
        prepStmt = connection.prepareStatement(cSQL);
        ResultSet result = prepStmt.executeQuery();
        if (result.next()) {
            while (result.next()) {
                DS_TCSTCC lea = new DS_TCSTCC();
                lea.setTccid(result.getString(1));
                lea.setTccname(result.getString(2));
                output.add(lea);
            }
        }
    } catch (SQLException e) {
        prepStmt = null;
        e.printStackTrace();
    }
    return output;
}

From source file:com.iucosoft.eavertizare.dao.impl.FirmaDaoImpl.java

@Override
public Firma findByName(String numeFirma) {

    String query = "select * from firme where nume_firma='" + numeFirma + "'";
    Firma firma = null;/*from  ww  w .  ja  v a 2s  .c  o  m*/

    try (Connection con = dataSource.getConnection();
            PreparedStatement ps = con.prepareStatement(query);
            ResultSet rs = ps.executeQuery();) {

        if (rs.next()) {

            Configuratii configuratie = configuratiiDao.findById(rs.getInt("id_configuratie"));

            firma = new Firma(rs.getInt("id"), rs.getString("nume_firma"), rs.getString("adresa"),
                    rs.getString("descriere"), rs.getString("tabela_clienti"), rs.getString("mesaj_clienti"),
                    configuratie);
        }
    } catch (SQLException e) {
        e.printStackTrace();
    }
    return firma;
}

From source file:cern.c2mon.server.cache.dbaccess.impl.CacheDbLifecycle.java

@Override
public void stop() {
    LOGGER.info("Closing down cache DB connections (only available for Apache BasicDataSource)");
    try {/*from w  ww .ja v  a 2s.c  om*/
        if (cacheDataSource instanceof BasicDataSource)
            ((BasicDataSource) cacheDataSource).close();
    } catch (SQLException ex) {
        LOGGER.error("Exception caught while closing down cache DB connections.", ex);
        ex.printStackTrace();
    }
}

From source file:com.ws.WS_TCS.java

@GET
@Produces(MediaType.APPLICATION_JSON)// ww w.ja v  a  2s .c o  m
public List<DS_PSMADP> GetDepartment() throws IOException {
    List<DS_PSMADP> output = new ArrayList<DS_PSMADP>();
    PreparedStatement prepStmt = null;
    try {
        String cSQL = "SELECT ADPDPT, ADPNM2 FROM PSMADP WHERE ADPEDT = ? AND ADPUSE <> ? ORDER BY ADPDPT";
        prepStmt = connection.prepareStatement(cSQL);
        prepStmt.setString(1, "99999999");
        prepStmt.setString(2, "X");
        ResultSet result = prepStmt.executeQuery();
        if (result.next()) {
            while (result.next()) {
                DS_PSMADP dep = new DS_PSMADP();
                dep.setDepid(result.getString(1));
                dep.setDepname(result.getString(2));
                output.add(dep);
            }
        }
    } catch (SQLException e) {
        prepStmt = null;
        e.printStackTrace();
    }
    return output;
}

From source file:com.iucosoft.eavertizare.dao.impl.FirmaDaoImpl.java

@Override
public Firma findById(int idFirma) {

    String query = "select * from firme where id=" + idFirma;
    List<Firma> firmaList = new ArrayList<>();
    Firma firma = null;//from   w w w .  j  a  va2s .  c  om

    try (Connection con = dataSource.getConnection();
            PreparedStatement ps = con.prepareStatement(query);
            ResultSet rs = ps.executeQuery();) {

        if (rs.next()) {

            Configuratii configuratie = configuratiiDao.findById(rs.getInt("id_configuratie"));

            firma = new Firma(rs.getInt("id"), rs.getString("nume_firma"), rs.getString("adresa"),
                    rs.getString("descriere"), rs.getString("tabela_clienti"), rs.getString("mesaj_clienti"),
                    configuratie);
        }
    } catch (SQLException e) {
        e.printStackTrace();
    }
    return firma;
}

From source file:org.projecthdata.ehr.viewer.service.HDataSyncService.java

/**
 * For the given Section, add it to the root entries table. It will also
 * retrieve the atom feed for the section and add each Entry into the
 * metadata table. This function will recursively call itself to process
 * child sections/*from  w w w. j  a v  a 2 s.c o  m*/
 * 
 * @param rootOperations
 * @param section
 */
private void processSection(RootOperations rootOperations, Section section) {
    try {

        Dao<RootEntry, Integer> rootDao = hDataOrmManager.getDatabaseHelper().getRootEntryDao();
        Dao<SectionDocMetadata, Integer> sectionDao = hDataOrmManager.getDatabaseHelper()
                .getSectionDocMetadataDao();

        RootEntry rootEntry = new RootEntry();
        rootEntry.copy(section);
        // persist each entry in the database
        rootDao.create(rootEntry);

        AtomFeed sectionMetadata = rootOperations.getSectionFeed(section);
        for (Entry entry : sectionMetadata.getEntries()) {
            SectionDocMetadata metadata = new SectionDocMetadata();
            metadata.copy(entry);
            metadata.setRootEntry(rootEntry);
            sectionDao.create(metadata);
        }
        if (section.getSections() != null) {
            // recursively process child sections
            for (Section childSection : section.getSections()) {
                processSection(rootOperations, childSection);
            }
        }
    } catch (SQLException sqle) {
        Log.e(TAG, "Error inserting into database", sqle);
        sqle.printStackTrace();
    }
}

From source file:com.ws.WS_TCS.java

@Path("/GetPerLel/{account}")
@GET/*from  w ww .ja  v  a 2 s  . co  m*/
@Produces(MediaType.APPLICATION_JSON)
public List<DS_TCSTCE> GetPerLel(@PathParam("account") String account) {
    List<DS_TCSTCE> output = new ArrayList<DS_TCSTCE>();
    PreparedStatement prepStmt = null;
    try {
        String cSQL = "SELECT TCENAM, TCEBTD, TCEALL, TCETKB, TCETKT FROM TCSTCE WHERE TCELJD = 0 AND TCEEMP = ?";
        prepStmt = connection.prepareStatement(cSQL);
        prepStmt.setString(1, account);
        ResultSet result = prepStmt.executeQuery();
        while (result.next()) {
            DS_TCSTCE acc = new DS_TCSTCE();
            acc.setNam(result.getString(1));
            acc.setBtd(result.getString(2));
            acc.setAll(result.getString(3));
            acc.setTkb(result.getString(4));
            acc.setTkt(result.getString(5));
            output.add(acc);
        }
    } catch (SQLException e) {
        prepStmt = null;
        e.printStackTrace();
    }
    return output;
}

From source file:fitmon.WorkoutData.java

public double calBurned(String date, int userId) throws SQLException {
    PreparedStatement st = null;//from   ww  w . ja  v  a2s  .  c  om
    Connection conn = null;
    double calBurned = 0;
    try {
        String query = "select date,sum(calories) from Workout where userId=" + userId + " and date='" + date
                + "'";
        Class.forName("com.mysql.jdbc.Driver");
        conn = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/fitmon", "root",
                "april-23");
        st = conn.prepareStatement(query);
        conn.setAutoCommit(false);
        ResultSet rs = st.executeQuery(query);
        while (rs.next()) {

            calBurned = rs.getDouble("sum(calories)");

        }
        st.close();
        conn.close();

    } catch (ClassNotFoundException ce) {
        ce.printStackTrace();
    } catch (SQLException se) {
        se.printStackTrace();
    } catch (Exception e) {
        //Handle errors for Class.forName
        e.printStackTrace();
    } finally {

        if (st != null) {
            st.close();
        }

        if (conn != null) {
            conn.close();
        }

    }
    return calBurned;
}