Bonjour à tous,

J'ai un soucis lorsque j'essaie de créer des "connections" vers MySql. J'ai bien le Jar jdbc fournit par MySql et le connecteur Odbc (sous windows) fournit également par mysql.

Ma méthode pour obtenir des connections est la suivante :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
 
protected Connection getConnection() throws PersistenceException {
 
        try {
            Class.forName(jdbcDriver).newInstance();
            Connection con = DriverManager.getConnection(jdbcUrl, jdbcLogin, jdbcPassword);
            return con;
        } catch (Exception e) {
            logger.error(e.getMessage());
            throw new PersistenceException(e);
        }
    }
Mon code marche la 1ere fois, la 2eme mais plante au 3e passage de façon systèmatique :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
 
[MySQL][ODBC 5.1 Driver]Can't connect to MySQL server on 'localhost' (10061)
 
java.sql.SQLException: [MySQL][ODBC 5.1 Driver]Can't connect to MySQL server on 'localhost' (10061)
    at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
    at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
    at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(Unknown Source)
    at sun.jdbc.odbc.JdbcOdbcConnection.initialize(Unknown Source)
    at sun.jdbc.odbc.JdbcOdbcDriver.connect(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
Quelqu'un aurait une idée ?

Merci d'avance.
Titi.