Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String url = "jdbc:mysql://localhost:3306/supsales";
- String root = "root";
- String password= "";
- Connection connexion = null;
- try {
- connexion = DriverManager.getConnection(url, root , password);
- /* Ici, nous placerons nos requêtes vers la BDD */
- statement = connexion.createStatement();
- resultat = statement.executeQuery( "SELECT pseudo, email, nom, prenom FROM utilisateur;" );
- } catch ( SQLException e ) {
- messages.add("Erreur lors de la connexion " + e);
- } finally {
- if ( resultat != null ) {
- try {
- resultat.close();
- } catch ( SQLException ignore ) {
- }
- }
- messages.add( "Fermeture de l'objet Statement." );
- if ( statement != null ) {
- try {
- statement.close();
- } catch ( SQLException ignore ) {
- }
- }
- messages.add( "Fermeture de l'objet Connection." );
- if ( connexion != null ) {
- try {
- connexion.close();
- } catch ( SQLException ignore ) {
- }
- }
- return messages;
- }
Add Comment
Please, Sign In to add comment