List of usage examples for java.sql SQLException printStackTrace
public void printStackTrace()
From source file:com.paladin.sys.db.QueryHelper.java
/** * ?// w w w.jav a 2 s .com * * @param rs * @return Map<String, String> Map * @throws SQLException */ private static Map<String, Object> getMapFromRs(final ResultSet rs) { Map<String, Object> t_map = new HashMap<String, Object>(); int columnCount = 0; try { columnCount = rs.getMetaData().getColumnCount();// ? // ???? for (int i = 0; i < columnCount; i++) { t_map.put(rs.getMetaData().getColumnName(i + 1).toUpperCase(), Tools.null2String(rs.getString(i + 1)));// ??map } } catch (SQLException e) { e.printStackTrace(); } return t_map; }
From source file:com.paladin.sys.db.QueryHelper.java
/** * Spring queryForList??//from w ww.j a va2 s. c om * * @param _sql * @param _par * @return */ public static List<Map<String, Object>> queryList(String _sql, Object... _par) { MapListHandler handler = new MapListHandler() { @Override protected Map<String, Object> handleRow(ResultSet __rs) throws SQLException { return getMapFromRs(__rs); } }; try { return RUNNER.query(getConnection(), _sql, handler, _par); } catch (SQLException e) { e.printStackTrace(); } finally { DBManager.closeConnection(); } return null; }
From source file:com.skilrock.lms.common.db.DBConnect.java
public static void closeStmt(Statement stmt) { try {/*from w w w . j a v a2 s . c om*/ if (stmt == null) logger.info("Statement Already Closed Or Empty"); else stmt.close(); } catch (SQLException ex) { logger.error("Problem While closing Statement"); ex.printStackTrace(); } }
From source file:com.skilrock.lms.common.db.DBConnect.java
public static void closeRs(ResultSet rs) { try {/*from ww w .j av a2 s. co m*/ if (rs == null) logger.info("ResultSet Already Closed Or Empty"); else rs.close(); } catch (SQLException ex) { logger.error("Problem While closing ResultSet"); ex.printStackTrace(); } }
From source file:com.glaf.core.jdbc.DBConnectionFactory.java
public static String getDatabaseType(Connection connection) { if (connection != null) { String databaseProductName = null; try {/* www. j a v a 2 s . co m*/ DatabaseMetaData databaseMetaData = connection.getMetaData(); databaseProductName = databaseMetaData.getDatabaseProductName(); } catch (SQLException ex) { ex.printStackTrace(); throw new RuntimeException(ex); } String dbType = databaseTypeMappings.getProperty(databaseProductName); if (dbType == null) { throw new RuntimeException( "couldn't deduct database type from database product name '" + databaseProductName + "'"); } return dbType; } return null; }
From source file:com.skilrock.lms.common.db.DBConnect.java
public static void closeCon(Connection con) { try {//from w w w . jav a 2 s. com if (con == null || con.isClosed()) logger.info("Connection Already Closed Or Empty"); else con.close(); } catch (SQLException ex) { logger.error("Problem While closing Connection"); ex.printStackTrace(); } }
From source file:com.anyi.gp.license.RegisterTools.java
public static String getDBServerURL() { Connection conn = null;/* w w w .j a va2 s.co m*/ try { conn = DAOFactory.getInstance().getConnection(); if (conn != null) { DatabaseMetaData meta = conn.getMetaData(); return (meta.getURL() + ":" + meta.getUserName()).toUpperCase(); } } catch (SQLException e) { e.printStackTrace(); } finally { DBHelper.closeConnection(conn); } return ""; }
From source file:com.cgdecker.guice.jdbc.Hsqldb.java
private static void setUpDatabase(DataSource dataSource) { Connection conn = null;/*from w ww .j a va2s . c o m*/ try { conn = dataSource.getConnection(); PreparedStatement pS = conn.prepareStatement("SET DATABASE TRANSACTION CONTROL MVCC"); pS.executeUpdate(); pS.close(); pS = conn.prepareStatement("DROP TABLE foo IF EXISTS"); pS.executeUpdate(); pS.close(); pS = conn.prepareStatement("CREATE TABLE foo ( id INTEGER, name VARCHAR(100) )"); pS.executeUpdate(); pS.close(); } catch (SQLException e) { throw new RuntimeException(e); } finally { if (conn != null) { try { conn.close(); } catch (SQLException e) { e.printStackTrace(); } } } }
From source file:com.skilrock.lms.common.db.DBConnect.java
public static void closePstmt(PreparedStatement pstm) { try {//from www .jav a2s.c om if (pstm == null) logger.info("PreparedStatement Already Closed Or Empty"); else pstm.close(); } catch (SQLException ex) { logger.error("Problem While closing PreparedStatement"); ex.printStackTrace(); } }
From source file:com.skilrock.lms.common.db.DBConnect.java
public static void closeCstmt(CallableStatement cstmt) { try {// ww w. j a va2 s .c o m if (cstmt == null) logger.info("Callable Statement Already Closed Or Empty"); else cstmt.close(); } catch (SQLException ex) { logger.error("Problem While closing Callable Statement"); ex.printStackTrace(); } }