Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. package testing;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.PreparedStatement;
  6. import java.sql.ResultSet;
  7.  
  8.  
  9. public class Aplikacija {
  10. public static void main(String[] args) throws Exception {
  11.  
  12. Class.forName("com.mysql.jdbc.Driver");
  13.  
  14. Connection con = DriverManager.getConnection("jdbc:mysql://localhost/testtablica", "root", "qwertz");
  15.  
  16. PreparedStatement stmt = con.prepareStatement("SELECT ime FROM Osobe");
  17.  
  18. ResultSet rs = stmt.executeQuery();
  19.  
  20. while(rs.next()) {
  21. System.out.println(rs.getString(2));
  22. }
  23.  
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement