Advertisement
Reykez

kod

Feb 12th, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. Tak mam napisane to ja (fragment klasy, jedna funkcja):
  2.  
  3. public static void downloadFromDatabase(String database, String where, String item) { // checking login from database
  4. try {
  5. con = DriverManager.getConnection("jdbc:mysql://reykez.pl:3306/reykez_xxxxxx" , "reykez_xxxxxx" , "xxxxxxxx");
  6. st = con.createStatement();
  7. rs = st.executeQuery("select * from " + database + " WHERE " + where + " = '" + item + "'"); // select from nickname
  8. } catch(Exception e) { e.printStackTrace(); }
  9. }
  10. ---------------------------------------------------------------------------------------
  11. Ale ten sam kod można napisać na przykład tak:
  12. public static void downloadFromDatabase(String database, String where, String item)
  13. {
  14. try {
  15. con = DriverManager.getConnection("jdbc:mysql://reykez.pl:3306/reykez_xxxxxx" , "reykez_xxxxxx" , "xxxxxxxx");
  16. st = con.createStatement();
  17. rs = st.executeQuery("select * from " + database + " WHERE " + where + " = '" + item + "'");
  18. }
  19. catch(Exception e)
  20. {
  21. e.printStackTrace();
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement