Advertisement
Guest User

Untitled

a guest
Mar 29th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. import java.sql.*;
  2.  
  3. public class tampil {
  4. public static void main(String args[]){
  5. try{
  6. Class.forName("com.mysql.jdbc.Driver");
  7. Connection con=DriverManager.getConnection(
  8. "jdbc:mysql://localhost/pertemuan7","root","");
  9. //here sonoo is database name, root is username and password
  10. Statement stmt=con.createStatement();
  11. ResultSet rs=stmt.executeQuery("select * from latihan");
  12. while(rs.next())
  13. System.out.println(rs.getInt(1)+" "+rs.getString(2)+" "+rs.getInt(3));
  14. con.close();
  15. }catch(Exception e){ System.out.println(e);}
  16. }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement