public List getBooksByCost(String cost) { List al = new ArrayList(); try { con = JdbcUtil.getMysqlConnection(); ps = con.prepareStatement("select *from jlcbooks where cost=?"); ps.setString(1, cost); rs = ps.executeQuery(); while (rs.next()) { Book bo = new Book(); bo.setBid(rs.getString(1)); bo.setBname(rs.getString(2)); bo.setAuthor(rs.getString(3)); bo.setPub(rs.getString(4)); bo.setCost(rs.getString(5)); bo.setEdi(rs.getString(6)); bo.setIsbn(rs.getString(7)); al.add(bo); } } catch (Exception e) { e.printStackTrace(); } finally { JdbcUtil.cleanup(ps, con); } return al; }
@Override public void processAfterCopy( MaintenanceDocument document, Map<String, String[]> requestParameters) { Book book = ((Book) document.getNewMaintainableObject().getDataObject()); book.setIsbn(null); super.processAfterCopy(document, requestParameters); }
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_save) { if (title.getText().toString().isEmpty()) title.setError("This field can't be empty."); else if (!price.getText().toString().matches("^\\d+$")) price.setError("It must be an integer."); else { currentBook.setTitle(title.getText().toString()); currentBook.setAuthor(author.getText().toString()); currentBook.setCourse(course.getText().toString()); currentBook.setPrice(Integer.valueOf(price.getText().toString())); currentBook.setIsbn(isbn.getText().toString()); SimpleBookManager.getInstance().saveChanges(this); setResult(RESULT_OK); finish(); return true; } } else if (id == android.R.id.home) { onBackPressed(); return true; } return super.onOptionsItemSelected(item); }
@Override public void onQueryComplete(ResultSetFuture rsf) { log.info("QueryCompleted"); Row row; try { row = rsf.get().one(); } catch (Exception e) { throw new RuntimeException("Failed to get ResultSet from ResultSetFuture", e); } book = new Book(); book.setIsbn(row.getString("isbn")); book.setTitle(row.getString("title")); book.setAuthor(row.getString("author")); book.setPages(row.getInt("pages")); done = true; log.info("DONE"); }
public Book getBookByBid(String bid) { Book bo = null; try { con = JdbcUtil.getMysqlConnection(); ps = con.prepareStatement("select *from jlcbooks where bid=?"); ps.setString(1, bid); rs = ps.executeQuery(); if (rs.next()) { bo = new Book(); bo.setBid(rs.getString(1)); bo.setBname(rs.getString(2)); bo.setAuthor(rs.getString(3)); bo.setPub(rs.getString(4)); bo.setCost(rs.getString(5)); bo.setEdi(rs.getString(6)); bo.setIsbn(rs.getString(7)); } } catch (Exception e) { e.printStackTrace(); } finally { JdbcUtil.cleanup(ps, con); } return bo; }