Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. package lab9;
  2.  
  3. //import javax.swing.JMenu;
  4. import java.sql.Connection;
  5. import java.sql.DriverManager;
  6. import java.sql.ResultSet;
  7. import java.sql.SQLException;
  8.  
  9. import com.mysql.jdbc.Statement;
  10.  
  11. class MainApp{
  12. public static void main(String []args)
  13. throws SQLException, InstantiationException, IllegalAccessException, ClassNotFoundException{
  14. String url = "jdbc:mysql://localhost:3306/test";
  15. Statement sql;
  16. ResultSet rs;
  17. Class.forName("com.mysql.jdbc.Driver").newInstance ();
  18. Connection con = DriverManager.getConnection(url, "root", "root");
  19. sql = (Statement) con.createStatement();
  20. rs = sql.executeQuery("select * from Persoane");
  21. while(rs.next())
  22. System.out.println("ID="+rs.getInt("ID")+", Nume= "+ rs.getString("Nume")+ ", Varsta="+rs.getInt(3));
  23. MyFrm frm=new MyFrm(sql);
  24. frm.setVisible(true);
  25. con.close();
  26. rs.close();
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement