Advertisement
Guest User

Untitled

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