Guest User

Untitled

a guest
Mar 28th, 2016
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.73 KB | None | 0 0
  1.     public void updateTable(String tableName, String poleSzukane, String wartoscSzukana, String poleZmienne, String nowaWartosc){
  2.         Statement statement;
  3.         Connection connection;
  4.         try{
  5.             Class.forName("org.sqlite.JDBC");
  6.             connection = DriverManager.getConnection("jdbc:sqlite:" +tableName+ ".db");
  7.             statement = connection.createStatement();
  8.             String query = "UPDATE " + tableName + " SET " + poleZmienne+ " = \""+nowaWartosc+"\" WHERE "+poleSzukane+" = \""+wartoscSzukana+"\"";
  9.             ResultSet wynik = statement.executeQuery(query);
  10.             statement.close();
  11.             connection.close();
  12.         }catch(Exception e){
  13.     e.printStackTrace();
  14.         }
  15.     }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment