Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public boolean saveResearch(int userId, Filtre fltr){
- Connection conn = null;
- PreparedStatement stShop = null;
- try{
- conn=getConnection();
- conn.setAutoCommit(false);
- stShop = conn.prepareStatement("insert into history set idclient=?,research=? "); //la requ�te
- stShop.setInt(1, userId) ;
- stShop.setString(2, fltr.getResearch());
- stShop.executeUpdate();
- conn.commit();
- } catch (BatchUpdateException e){
- System.out.println("Research is already in the database");
- return false;
- } catch (SQLException e){
- System.out.println("Error connecting to the database");
- e.printStackTrace();
- return false;
- } finally {
- if (stShop != null){
- try {
- stShop.close();
- } catch (Exception ex) {
- }
- }
- if (conn != null) {
- try {
- conn.close();
- } catch (Exception e) {
- }
- }
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement