Advertisement
Guest User

zemerogùnosdifnvmsd

a guest
Dec 12th, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. package finall;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.SQLException;
  6. import java.util.Properties;
  7.  
  8. public class Test {
  9. public static void main(String[] args) throws SQLException {
  10.  
  11. String userName = "root";
  12. String password = "";
  13. String serverName = "localhost";
  14. //Attention, sous MAMP, le port est 8889
  15. String portNumber = "3306";
  16. String tableName = "personne";
  17. // iL faut une base nommee testPersonne !
  18. String dbName = "testpersonne";
  19. // creation de la connection
  20. Properties connectionProps = new Properties();
  21. connectionProps.put("user", userName);
  22. connectionProps.put("password", password);
  23. String urlDB = "jdbc:mysql://" + serverName + ":";
  24. urlDB += portNumber + "/" + dbName;
  25. Connection connect = DriverManager.getConnection(urlDB, connectionProps);
  26.  
  27. connect = DBConnection.getConnection();
  28.  
  29. DBConnection.setNomDB("test");
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement