Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package finall;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.SQLException;
- import java.util.Properties;
- public class Test {
- public static void main(String[] args) throws SQLException {
- String userName = "root";
- String password = "";
- String serverName = "localhost";
- //Attention, sous MAMP, le port est 8889
- String portNumber = "3306";
- String tableName = "personne";
- // iL faut une base nommee testPersonne !
- String dbName = "testpersonne";
- // creation de la connection
- Properties connectionProps = new Properties();
- connectionProps.put("user", userName);
- connectionProps.put("password", password);
- String urlDB = "jdbc:mysql://" + serverName + ":";
- urlDB += portNumber + "/" + dbName;
- Connection connect = DriverManager.getConnection(urlDB, connectionProps);
- connect = DBConnection.getConnection();
- DBConnection.setNomDB("test");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement