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:org.owasp.webgoat.session.DatabaseUtilities.java

/**
 * <p>returnConnection.</p>/*from ww  w.ja v a 2  s  .co m*/
 *
 * @param user a {@link java.lang.String} object.
 */
public static synchronized void returnConnection(String user) {
    try {
        Connection connection = connections.get(user);
        if (connection == null || connection.isClosed())
            return;

        if (connection.getMetaData().getDatabaseProductName().toLowerCase().contains("oracle"))
            connection.close();
    } catch (SQLException sqle) {
        sqle.printStackTrace();
    }
}

From source file:Main.java

public static void close(Connection connection) {
    try {/*w  w  w .  j a v  a 2s  .com*/
        if (connection != null) {
            connection.close();
        }
    } catch (SQLException e) {
        e.printStackTrace();
    }
}

From source file:Main.java

public static void close(Statement st) {
    try {/*from   ww  w. j  a  va  2s .  c o m*/
        if (st != null) {
            st.close();
        }
    } catch (SQLException e) {
        e.printStackTrace();
    }
}

From source file:Main.java

public static void close(ResultSet rs) {
    try {/*from   w  w w .j  av a 2  s .  c o m*/
        if (rs != null) {
            rs.close();
        }
    } catch (SQLException e) {
        e.printStackTrace();
    }
}

From source file:Main.java

public static void rollback(Connection connection) {
    try {//from   www.  ja v a2 s .co  m
        if (connection != null) {
            connection.rollback();
        }
    } catch (SQLException e) {
        e.printStackTrace();
    }
}

From source file:de.dakror.virtualhub.server.DBManager.java

public static void rename(Packet4Rename packet) {
    try {//from w  w  w  .  jav a2  s .  com
        connection.createStatement()
                .executeUpdate("UPDATE ETICETS SET PATH = \"" + packet.getNewFile().getPath().replace("\\", "/")
                        + "\" WHERE PATH = \"" + packet.getOldFile().getPath().replace("\\", "/") + "\"");
        connection.createStatement()
                .executeUpdate("UPDATE TAGS SET PATH = \"" + packet.getNewFile().getPath().replace("\\", "/")
                        + "\" WHERE PATH = \"" + packet.getOldFile().getPath().replace("\\", "/") + "\"");
    } catch (SQLException e) {
        e.printStackTrace();
    }
}

From source file:dbutils.ExampleJDBC.java

/**
 * MapListHandler ResultSet??ListListMap
 *///  w  ww.  j av a2 s.  c om
public static void getMapListData() {
    Connection conn = getConnection();
    QueryRunner qr = new QueryRunner();
    try {
        List results = (List) qr.query(conn, "SELECT id, name, gender, age, team_id FROM test_student",
                new MapListHandler());
        for (Object result : results) {
            Map map = (Map) result;
            System.out.println(
                    "id=" + map.get("id") + " name=" + map.get("name") + " gender=" + map.get("gender"));
        }
    } catch (SQLException e) {
        e.printStackTrace();
    } finally {
        DbUtils.closeQuietly(conn);
    }
}

From source file:com.khartec.waltz.jobs.InvolvementHarness.java

private static void viaJdbc(DataSource dataSource) {

    try (Connection conn = dataSource.getConnection();) {

        System.out.println("-- jdbc start");
        long start = System.currentTimeMillis();

        PreparedStatement pstmt = conn.prepareStatement(qry);
        ResultSet rs = pstmt.executeQuery();

        int c = 0;

        while (rs.next()) {
            c++;//from   ww  w . j a  va2 s  .  c  o m
        }

        System.out.println(c);
        long duration = System.currentTimeMillis() - start;
        System.out.println("-- jdbc end " + duration);
    } catch (SQLException e) {
        e.printStackTrace();
    }
}

From source file:dbutils.ExampleJDBC.java

/**
 * ?/*from  w w w .jav a  2  s .c  o  m*/
 */
public static void insertAndUpdateData() throws SQLException {
    Connection conn = getConnection();
    QueryRunner qr = new QueryRunner();
    try {
        //??insert?
        Object[] insertParams = { "John Doe", "", 12, 3 };
        int inserts = qr.update(conn, "INSERT INTO test_student(name,gender,age,team_id) VALUES (?,?,?,?)",
                insertParams);
        System.out.println("inserted " + inserts + " data");

        Object[] updateParams = { "John Doe Update", "John Doe" };
        int updates = qr.update(conn, "UPDATE test_student SET name=? WHERE name=?", updateParams);
        System.out.println("updated " + updates + " data");
    } catch (SQLException e) {
        e.printStackTrace();
        conn.rollback();
    } finally {
        DbUtils.close(conn);
    }
}

From source file:com.voa.weixin.db.WeixinHibernateUtil.java

public static void shutDown() {
    closeSession();//w  ww . j  a  v  a 2  s .c  o m
    tLocalsess.set(null);
    tLocalsess.remove();
    tLocaltx.set(null);
    tLocaltx.remove();

    Session currSession = sessionFactory.getCurrentSession();
    if (currSession != null)
        currSession.close();
    sessionFactory.close();

    try {
        DataSources.unpooledDataSource();
    } catch (SQLException e) {
        e.printStackTrace();
    }
    log.info("WeixinHibernateUtil shutDown!");
}