Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //metoda w servlecie
- baza.przelew(connection,"Jacek","Kapusta",5000);
- //cialo metody
- public void przelew(Connection connection,String nazwisko,String nazwisko2,int ile){
- int x=ile*(-1);
- baza.updatekonto(connection,"Kapusta",ile);
- baza.updatekonto(connection,"jacek",x);
- baza.updatehistoria(connection,"Kapusta","Jacek",ile);
- baza.updatehistoria(connection,"Jacek","Kapusta",x);
- }
- //cialo updatekonto
- public static void updatekonto(Connection connection, String nazwisko, int ile){
- String b="";
- Statement stmt = null;
- try {
- stmt = connection.createStatement();
- } catch (SQLException e) {
- e.printStackTrace();
- //writer.println("NIE CHODZE1sql");
- }
- try {
- String a="Update konto set kasa=kasa";
- if(ile>=0){
- b="+";
- b+=String.valueOf(ile);
- }
- else{
- //b="-";
- b+=String.valueOf(ile);
- }
- String c=" where nazwisko='";
- c+=nazwisko;
- c+="';";
- //String d=a+b+c+;
- stmt.executeUpdate(a+b+c);
- } catch (SQLException ex) {
- ex.printStackTrace();
- }
- //cialo upddadtehistoria
- public static void updatehistoria(Connection connection, String nazwisko, String nazwisko2, int ile){
- String b="";
- Statement stmt = null;
- try {
- stmt = connection.createStatement();
- } catch (SQLException e) {
- e.printStackTrace();
- System.out.println("error1");
- //writer.println("NIE CHODZE1sql");
- }
- try {
- String a="Insert into historia values('";
- b=nazwisko+"','"+nazwisko2+"',"+String.valueOf(ile)+");";
- System.out.println(a+b);
- //String d=a+b+c+;
- stmt.executeUpdate(a+b);
- } catch (SQLException ex) {
- ex.printStackTrace();
- System.out.println("error2");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement