List of usage examples for java.sql SQLException printStackTrace
public void printStackTrace()
From source file:controladores.PeliculasController.java
public ModelAndView inicio(HttpServletRequest request, HttpServletResponse response) throws Exception { this.getConnection(request.getServletContext()); ArrayList al = new ArrayList(); try {/*from w w w. j a va 2 s . c o m*/ Statement stmt = this.conexion.createStatement(); ResultSet rs = stmt .executeQuery("SELECT ids, nombre, observaciones, tipopeli, precio, foto FROM peliculas"); while (rs.next()) { Pelicula p = new Pelicula(rs.getInt("ids"), rs.getString("nombre"), rs.getString("tipopeli"), rs.getString("observaciones"), rs.getInt("precio"), rs.getString("foto").toUpperCase()); al.add(p); } rs.close(); } catch (SQLException ex) { ex.printStackTrace(); } ModelAndView mv = new ModelAndView("index"); mv.addObject("peliculas", al); mv.addObject("metodo", "inicio"); return mv; }
From source file:com.its.web.services.LicensesTypesService.java
public List<LicenseType> findByName(LicenseType licenseType) { Map<String, Object> fieldValues = new HashMap<String, Object>(); fieldValues.put("name", licenseType.getName()); fieldValues.put("product_id", licenseType.getProductId()); try {//from ww w. jav a 2 s. co m return database.getLicenseTypeDao().queryForFieldValues(fieldValues); } catch (SQLException e) { e.printStackTrace(); return null; } }
From source file:com.its.web.services.LicensesTypesService.java
public List<LicenseType> findFullTypeByProduct(Long productId) { Map<String, Object> fieldValues = new HashMap<String, Object>(); fieldValues.put("product_id", productId); fieldValues.put("type_is_full", true); try {// w w w.ja v a2s .com return database.getLicenseTypeDao().queryForFieldValues(fieldValues); } catch (SQLException e) { e.printStackTrace(); return null; } }
From source file:com.its.web.services.LicensesTypesService.java
public List<LicenseType> findTrialTypeByProduct(Long productId) { Map<String, Object> fieldValues = new HashMap<String, Object>(); fieldValues.put("product_id", productId); fieldValues.put("type_is_full", false); try {/*from w w w. j a va 2 s. c om*/ return database.getLicenseTypeDao().queryForFieldValues(fieldValues); } catch (SQLException e) { e.printStackTrace(); return null; } }
From source file:com.fufang.testcase.his.GetMaterialContents.java
@BeforeTest public void insertSql() throws SQLException { SqlUtils c = new SqlUtils(); Con = c.mySqlConnection(dbUrl, dbUserName, dbPassword); String sql = "INSERT INTO `HISFC`.`t_community_contents` (`communityId`, `hisCode`, `contentsId`, `createDate`, `updateDate`) VALUES ('200301', 'J3001', 'a31cec32-d07c-4497-8841-fc864033676a', '2016-12-20 11:43:55', NULL);"; try {/*from w ww . ja v a2 s. c om*/ PreparedStatement pstmt = Con.prepareStatement(sql); pstmt.executeUpdate(sql); sql = "INSERT INTO `HISFC`.`t_contents_item` (`contentsItemId`, `headId`, `headCode`, `ffId`, `name`, `materialType`, `commonName`, `licenseNum`, `manufName`, `unitName`, `spec`, `dosage`, `isDelete`, `createDate`, `updateDate`) VALUES ('031bbb2f-bda6-4c29-8e8a-c34e3cdca46d', 'a31cec32-d07c-4497-8841-fc864033676a', 'HYJ', '215911', '', 'Z', '', '?Z20093536', '???', '', '10*12', '', NULL, '2016-09-19 16:32:06', NULL);"; pstmt.executeUpdate(sql); sql = "INSERT INTO `HISFC`.`t_contents_item` (`contentsItemId`, `headId`, `headCode`, `ffId`, `name`, `materialType`, `commonName`, `licenseNum`, `manufName`, `unitName`, `spec`, `dosage`, `isDelete`, `createDate`, `updateDate`) VALUES ('03281538-cfc7-4917-a73f-e4cfe2dd9da6', 'a31cec32-d07c-4497-8841-fc864033676a', 'HYJ', '209247', '', 'Z', '', '?G20090276', '????', '', '0.25*300', '', NULL, '2016-09-19 16:29:39', NULL);"; pstmt.executeUpdate(sql); } catch (SQLException e) { e.printStackTrace(); } finally { try { if (Con != null) Con.close(); } catch (SQLException se) { se.printStackTrace(); } } }
From source file:com.linecorp.platform.channel.sample.BusinessConnect.java
public List<String> getFriends(String currentMid, Connection connection) { List<String> output = new ArrayList<>(); try (PreparedStatement pstmt = connection.prepareStatement("SELECT mid FROM friends WHERE mid <> ?")) { pstmt.setString(1, currentMid);//from w w w . j ava 2s.c om ResultSet rs = pstmt.executeQuery(); while (rs.next()) { output.add(rs.getString("mid")); } } catch (SQLException e) { e.printStackTrace(); } return output; }
From source file:com.its.web.services.LicensesTypesService.java
public boolean saveOrUpdate(LicenseType licenseType) { try {//from w w w .j a v a 2 s .com if (licenseType.getId() == null) { database.getLicenseTypeDao().create(licenseType); } else { database.getLicenseTypeDao().update(licenseType); } } catch (SQLException e) { e.printStackTrace(); return false; } return true; }
From source file:com.linecorp.platform.channel.sample.BusinessConnect.java
public void addFriend(String mid, String displayName, Connection connection) { try (Statement stmt = connection.createStatement(); PreparedStatement pstmt = connection .prepareStatement("INSERT INTO friends VALUES (?, ?, now())");) { stmt.executeUpdate(/*from ww w . j a v a2s. c o m*/ "CREATE TABLE IF NOT EXISTS friends (mid VARCHAR(100) CONSTRAINT friends_pk PRIMARY KEY, " + "display VARCHAR(300), occasion TIMESTAMP)"); pstmt.setString(1, mid); pstmt.setString(2, displayName); pstmt.executeUpdate(); } catch (SQLException e) { e.printStackTrace(); } }
From source file:controladores.PeliculasController.java
public ModelAndView verMas(HttpServletRequest request, HttpServletResponse response) throws Exception { int pid = Integer.valueOf(request.getParameter("pid")); this.getConnection(request.getServletContext()); Pelicula p = null;/*from w w w . j a v a 2s .c o m*/ try { PreparedStatement ps = this.conexion.prepareStatement( "SELECT ids, nombre, observaciones, tipopeli, precio, foto FROM peliculas WHERE ids = ?"); ps.setInt(1, pid); ResultSet rs = ps.executeQuery(); if (rs.next()) { p = new Pelicula(rs.getInt("ids"), rs.getString("nombre"), rs.getString("tipopeli"), rs.getString("observaciones"), rs.getInt("precio"), rs.getString("foto").toUpperCase()); } rs.close(); } catch (SQLException ex) { ex.printStackTrace(); } ModelAndView mv; if (p != null) { mv = new ModelAndView("detalles"); mv.addObject("pelicula", p); } else { mv = this.inicio(request, response); } mv.addObject("metodo", "verMas"); return mv; }
From source file:io.kamax.mxisd.backend.wordpress.WordpressDirectoryProvider.java
public UserDirectorySearchResult search(String searchTerm, String query) { try (Connection conn = wordpress.getConnection()) { log.info("Will execute query: {}", query); try (PreparedStatement stmt = conn.prepareStatement(query)) { setParameters(stmt, searchTerm); try (ResultSet rSet = stmt.executeQuery()) { UserDirectorySearchResult result = new UserDirectorySearchResult(); result.setLimited(false); while (rSet.next()) { processRow(rSet).ifPresent(e -> { try { e.setUserId(MatrixID.from(e.getUserId(), mxCfg.getDomain()).valid().getId()); result.addResult(e); } catch (IllegalArgumentException ex) { log.warn("Ignoring result {} - Invalid characters for a Matrix ID", e.getUserId()); }// w ww. j a v a 2 s . com }); } return result; } } } catch (SQLException e) { e.printStackTrace(); throw new InternalServerError(e); } }