Bonjour à tous,

Je cherche une solution pour utiliser un pool de connexion par l'intermédiaire d'une DataSource.
J'avais en premier temps choisi DBCP, mais suite a des problèmes de connexion, j'ai décidé d’essayer C3P0.

Le problème est qu'a chaque requête, il m'a recréer un pool de connexion.
Voir le code de démarrage de mon application:
Pour démarrer sur la page d'accueil j'utilise 4 requêtes:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
INFO - -------------------------- Démarrage du programme --------------------------------------
DEBUG - Dimention:java.awt.Dimension[width=1597,height=812]
DEBUG - 1597.0 812.0
DEBUG - Setting up data source.mardi 10 avril 2012 9h 12 '54''
INFO - MLog clients using log4j logging.
INFO - Initializing c3p0-0.9.1.2 [built 21-May-2007 15:04:56; debug? true; trace: 10]
DEBUG - MBean: com.mchange.v2.c3p0:type=PooledDataSource[1hge0w18m1718bfh1sbwmn3|478e4327] registered.
DEBUG - MBean: com.mchange.v2.c3p0:type=PooledDataSource[1hge0w18m1718bfh1sbwmn3|478e4327] unregistered, in order to be reregistered after update.
DEBUG - MBean: com.mchange.v2.c3p0:type=PooledDataSource[1hge0w18m1718bfh1sbwmn3|478e4327] registered.
INFO - Initializing c3p0 pool... com.mchange.v2.c3p0.PoolBackedDataSource@5d799fd [ connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@c6e8001f [ acquireIncrement -> 3, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, debugUnreturnedConnectionStackTraces -> false, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 1hge0w18m1718bfh1sbwmn3|13e4a47e, idleConnectionTestPeriod -> 0, initialPoolSize -> 3, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 0, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 15, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 3, nestedDataSource -> com.mchange.v2.c3p0.DriverManagerDataSource@a764c2a0 [ description -> null, driverClass -> null, factoryClassLocation -> null, identityToken -> 1hge0w18m1718bfh1sbwmn3|e5d391d, jdbcUrl -> jdbc:mysql://*****/***, properties -> {user=******, password=******} ], preferredTestQuery -> null, propertyCycle -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, usesTraditionalReflectiveProxies -> false; userOverrides: {} ], dataSourceName -> null, factoryClassLocation -> null, identityToken -> 1hge0w18m1718bfh1sbwmn3|478e4327, numHelperThreads -> 3 ]
DEBUG - incremented pending_acquires: 1
DEBUG - incremented pending_acquires: 2
DEBUG - incremented pending_acquires: 3
DEBUG - com.mchange.v2.resourcepool.BasicResourcePool@48e29820 config: [start -> 3; min -> 3; max -> 15; inc -> 3; num_acq_attempts -> 30; acq_attempt_delay -> 1000; check_idle_resources_delay -> 0; mox_resource_age -> 0; max_idle_time -> 0; excess_max_idle_time -> 0; destroy_unreturned_resc_time -> 0; expiration_enforcement_delay -> 0; break_on_acquisition_failure -> false; debug_store_checkout_exceptions -> false]
DEBUG - acquire test -- pool size: 0; target_pool_size: 3; desired target? 1
DEBUG - awaitAvailable(): [unknown]
DEBUG - trace com.mchange.v2.resourcepool.BasicResourcePool@48e29820 [managed: 0, unused: 0, excluded: 0]
DEBUG - com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager@29abc69.acquireResource() returning. 
DEBUG - com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager@29abc69.acquireResource() returning. 
DEBUG - trace com.mchange.v2.resourcepool.BasicResourcePool@48e29820 [managed: 1, unused: 1, excluded: 0]
DEBUG - decremented pending_acquires: 2
DEBUG - trace com.mchange.v2.resourcepool.BasicResourcePool@48e29820 [managed: 1, unused: 0, excluded: 0] (e.g. com.mchange.v2.c3p0.impl.NewPooledConnection@1278dc4c)
DEBUG - Done.
DEBUG - trace com.mchange.v2.resourcepool.BasicResourcePool@48e29820 [managed: 2, unused: 1, excluded: 0] (e.g. com.mchange.v2.c3p0.impl.NewPooledConnection@1278dc4c)
DEBUG - decremented pending_acquires: 1
DEBUG - com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager@29abc69.acquireResource() returning. 
DEBUG - trace com.mchange.v2.resourcepool.BasicResourcePool@48e29820 [managed: 3, unused: 2, excluded: 0] (e.g. com.mchange.v2.c3p0.impl.NewPooledConnection@1278dc4c)
DEBUG - decremented pending_acquires: 0
DEBUG - trace com.mchange.v2.resourcepool.BasicResourcePool@48e29820 [managed: 3, unused: 2, excluded: 0] (e.g. com.mchange.v2.c3p0.impl.NewPooledConnection@1278dc4c)
DEBUG - Setting up data source.mardi 10 avril 2012 9h 12 '56''
DEBUG - MBean: com.mchange.v2.c3p0:type=PooledDataSource[1hge0w18m1718bfh1sbwmn3|78ff9053] registered.
DEBUG - MBean: com.mchange.v2.c3p0:type=PooledDataSource[1hge0w18m1718bfh1sbwmn3|78ff9053] unregistered, in order to be reregistered after update.
DEBUG - MBean: com.mchange.v2.c3p0:type=PooledDataSource[1hge0w18m1718bfh1sbwmn3|78ff9053] registered.
INFO - Initializing c3p0 pool... com.mchange.v2.c3p0.PoolBackedDataSource@4abe991b [ connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@a1550979 [ acquireIncrement -> 3, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, debugUnreturnedConnectionStackTraces -> false, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 1hge0w18m1718bfh1sbwmn3|495b0e2c, idleConnectionTestPeriod -> 0, initialPoolSize -> 3, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 0, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 15, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 3, nestedDataSource -> com.mchange.v2.c3p0.DriverManagerDataSource@e6229f7 [ description -> null, driverClass -> null, factoryClassLocation -> null, identityToken -> 1hge0w18m1718bfh1sbwmn3|6bb54362, jdbcUrl -> jdbc:mysql://*****/***, properties -> {user=******, password=******} ], preferredTestQuery -> null, propertyCycle -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, usesTraditionalReflectiveProxies -> false; userOverrides: {} ], dataSourceName -> null, factoryClassLocation -> null, identityToken -> 1hge0w18m1718bfh1sbwmn3|78ff9053, numHelperThreads -> 3 ]
DEBUG - incremented pending_acquires: 1
DEBUG - incremented pending_acquires: 2
DEBUG - incremented pending_acquires: 3
DEBUG - com.mchange.v2.resourcepool.BasicResourcePool@5e6458a6 config: [start -> 3; min -> 3; max -> 15; inc -> 3; num_acq_attempts -> 30; acq_attempt_delay -> 1000; check_idle_resources_delay -> 0; mox_resource_age -> 0; max_idle_time -> 0; excess_max_idle_time -> 0; destroy_unreturned_resc_time -> 0; expiration_enforcement_delay -> 0; break_on_acquisition_failure -> false; debug_store_checkout_exceptions -> false]
DEBUG - acquire test -- pool size: 0; target_pool_size: 3; desired target? 1
DEBUG - awaitAvailable(): [unknown]
DEBUG - trace com.mchange.v2.resourcepool.BasicResourcePool@5e6458a6 [managed: 0, unused: 0, excluded: 0]
DEBUG - com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager@55f157b.acquireResource() returning. 
DEBUG - trace com.mchange.v2.resourcepool.BasicResourcePool@5e6458a6 [managed: 1, unused: 1, excluded: 0]
DEBUG - decremented pending_acquires: 2
DEBUG - trace com.mchange.v2.resourcepool.BasicResourcePool@5e6458a6 [managed: 1, unused: 0, excluded: 0] (e.g. com.mchange.v2.c3p0.impl.NewPooledConnection@257b40fe)
DEBUG - Done.
DEBUG - com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager@55f157b.acquireResource() returning. 
DEBUG - trace com.mchange.v2.resourcepool.BasicResourcePool@5e6458a6 [managed: 2, unused: 1, excluded: 0] (e.g. com.mchange.v2.c3p0.impl.NewPooledConnection@257b40fe)
DEBUG - decremented pending_acquires: 1
DEBUG - com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager@55f157b.acquireResource() returning. 
DEBUG - trace com.mchange.v2.resourcepool.BasicResourcePool@5e6458a6 [managed: 3, unused: 2, excluded: 0] (e.g. com.mchange.v2.c3p0.impl.NewPooledConnection@257b40fe)
DEBUG - decremented pending_acquires: 0
DEBUG - trace com.mchange.v2.resourcepool.BasicResourcePool@5e6458a6 [managed: 3, unused: 2, excluded: 0] (e.g. com.mchange.v2.c3p0.impl.NewPooledConnection@257b40fe)
DEBUG - Setting up data source.mardi 10 avril 2012 9h 12 '56''
DEBUG - MBean: com.mchange.v2.c3p0:type=PooledDataSource[1hge0w18m1718bfh1sbwmn3|7966340c] registered.
DEBUG - MBean: com.mchange.v2.c3p0:type=PooledDataSource[1hge0w18m1718bfh1sbwmn3|7966340c] unregistered, in order to be reregistered after update.
DEBUG - MBean: com.mchange.v2.c3p0:type=PooledDataSource[1hge0w18m1718bfh1sbwmn3|7966340c] registered.
INFO - Initializing c3p0 pool... com.mchange.v2.c3p0.PoolBackedDataSource@6a680f7b [ connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@ae3f52b7 [ acquireIncrement -> 3, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, debugUnreturnedConnectionStackTraces -> false, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 1hge0w18m1718bfh1sbwmn3|5253c3f5, idleConnectionTestPeriod -> 0, initialPoolSize -> 3, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 0, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 15, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 3, nestedDataSource -> com.mchange.v2.c3p0.DriverManagerDataSource@86f4dd4 [ description -> null, driverClass -> null, factoryClassLocation -> null, identityToken -> 1hge0w18m1718bfh1sbwmn3|6bdc64a5, jdbcUrl -> jdbc:mysql://*****/***, properties -> {user=******, password=******} ], preferredTestQuery -> null, propertyCycle -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, usesTraditionalReflectiveProxies -> false; userOverrides: {} ], dataSourceName -> null, factoryClassLocation -> null, identityToken -> 1hge0w18m1718bfh1sbwmn3|7966340c, numHelperThreads -> 3 ]
DEBUG - incremented pending_acquires: 1
DEBUG - incremented pending_acquires: 2
DEBUG - incremented pending_acquires: 3
DEBUG - com.mchange.v2.resourcepool.BasicResourcePool@7461f533 config: [start -> 3; min -> 3; max -> 15; inc -> 3; num_acq_attempts -> 30; acq_attempt_delay -> 1000; check_idle_resources_delay -> 0; mox_resource_age -> 0; max_idle_time -> 0; excess_max_idle_time -> 0; destroy_unreturned_resc_time -> 0; expiration_enforcement_delay -> 0; break_on_acquisition_failure -> false; debug_store_checkout_exceptions -> false]
DEBUG - acquire test -- pool size: 0; target_pool_size: 3; desired target? 1
DEBUG - awaitAvailable(): [unknown]
DEBUG - trace com.mchange.v2.resourcepool.BasicResourcePool@7461f533 [managed: 0, unused: 0, excluded: 0]
DEBUG - com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager@6d732ed2.acquireResource() returning. 
DEBUG - trace com.mchange.v2.resourcepool.BasicResourcePool@7461f533 [managed: 1, unused: 1, excluded: 0]
DEBUG - decremented pending_acquires: 2
DEBUG - trace com.mchange.v2.resourcepool.BasicResourcePool@7461f533 [managed: 1, unused: 0, excluded: 0] (e.g. com.mchange.v2.c3p0.impl.NewPooledConnection@25071521)
DEBUG - Done.
DEBUG - com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager@6d732ed2.acquireResource() returning. 
DEBUG - trace com.mchange.v2.resourcepool.BasicResourcePool@7461f533 [managed: 2, unused: 1, excluded: 0] (e.g. com.mchange.v2.c3p0.impl.NewPooledConnection@25071521)
DEBUG - decremented pending_acquires: 1
DEBUG - com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager@6d732ed2.acquireResource() returning. 
DEBUG - trace com.mchange.v2.resourcepool.BasicResourcePool@7461f533 [managed: 3, unused: 2, excluded: 0] (e.g. com.mchange.v2.c3p0.impl.NewPooledConnection@25071521)
DEBUG - decremented pending_acquires: 0
DEBUG - trace com.mchange.v2.resourcepool.BasicResourcePool@7461f533 [managed: 3, unused: 2, excluded: 0] (e.g. com.mchange.v2.c3p0.impl.NewPooledConnection@25071521)
DEBUG - Setting up data source.mardi 10 avril 2012 9h 12 '57''
DEBUG - MBean: com.mchange.v2.c3p0:type=PooledDataSource[1hge0w18m1718bfh1sbwmn3|4824de7d] registered.
DEBUG - MBean: com.mchange.v2.c3p0:type=PooledDataSource[1hge0w18m1718bfh1sbwmn3|4824de7d] unregistered, in order to be reregistered after update.
DEBUG - MBean: com.mchange.v2.c3p0:type=PooledDataSource[1hge0w18m1718bfh1sbwmn3|4824de7d] registered.
INFO - Initializing c3p0 pool... com.mchange.v2.c3p0.PoolBackedDataSource@ddca63dd [ connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@56c12e26 [ acquireIncrement -> 3, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, debugUnreturnedConnectionStackTraces -> false, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 1hge0w18m1718bfh1sbwmn3|2e879860, idleConnectionTestPeriod -> 0, initialPoolSize -> 3, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 0, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 15, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 3, nestedDataSource -> com.mchange.v2.c3p0.DriverManagerDataSource@e3701fe7 [ description -> null, driverClass -> null, factoryClassLocation -> null, identityToken -> 1hge0w18m1718bfh1sbwmn3|351daa0e, jdbcUrl -> jdbc:mysql://*****/***, properties -> {user=******, password=******} ], preferredTestQuery -> null, propertyCycle -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, usesTraditionalReflectiveProxies -> false; userOverrides: {} ], dataSourceName -> null, factoryClassLocation -> null, identityToken -> 1hge0w18m1718bfh1sbwmn3|4824de7d, numHelperThreads -> 3 ]
DEBUG - incremented pending_acquires: 1
DEBUG - incremented pending_acquires: 2
DEBUG - incremented pending_acquires: 3
DEBUG - com.mchange.v2.resourcepool.BasicResourcePool@62803d5 config: [start -> 3; min -> 3; max -> 15; inc -> 3; num_acq_attempts -> 30; acq_attempt_delay -> 1000; check_idle_resources_delay -> 0; mox_resource_age -> 0; max_idle_time -> 0; excess_max_idle_time -> 0; destroy_unreturned_resc_time -> 0; expiration_enforcement_delay -> 0; break_on_acquisition_failure -> false; debug_store_checkout_exceptions -> false]
DEBUG - acquire test -- pool size: 0; target_pool_size: 3; desired target? 1
DEBUG - awaitAvailable(): [unknown]
DEBUG - trace com.mchange.v2.resourcepool.BasicResourcePool@62803d5 [managed: 0, unused: 0, excluded: 0]
DEBUG - com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager@6c04ab2f.acquireResource() returning. 
DEBUG - trace com.mchange.v2.resourcepool.BasicResourcePool@62803d5 [managed: 1, unused: 1, excluded: 0]
DEBUG - decremented pending_acquires: 2
DEBUG - trace com.mchange.v2.resourcepool.BasicResourcePool@62803d5 [managed: 1, unused: 0, excluded: 0] (e.g. com.mchange.v2.c3p0.impl.NewPooledConnection@2682d210)
DEBUG - Done.
DEBUG - com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager@6c04ab2f.acquireResource() returning. 
DEBUG - trace com.mchange.v2.resourcepool.BasicResourcePool@62803d5 [managed: 2, unused: 1, excluded: 0] (e.g. com.mchange.v2.c3p0.impl.NewPooledConnection@2682d210)
DEBUG - decremented pending_acquires: 1
DEBUG - com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager@6c04ab2f.acquireResource() returning. 
DEBUG - trace com.mchange.v2.resourcepool.BasicResourcePool@62803d5 [managed: 3, unused: 2, excluded: 0] (e.g. com.mchange.v2.c3p0.impl.NewPooledConnection@2682d210)
DEBUG - decremented pending_acquires: 0
DEBUG - trace com.mchange.v2.resourcepool.BasicResourcePool@62803d5 [managed: 3, unused: 2, excluded: 0] (e.g. com.mchange.v2.c3p0.impl.NewPooledConnection@2682d210)
INFO - Page d'Accueil
Dans ce code on retrouve un nouveau pool de connexion a chaque requête:
NewPooledConnection@1278dc4c
NewPooledConnection@257b40fe
NewPooledConnection@25071521
NewPooledConnection@2682d210
Donc je perd la connexion a chaque requête et se reconnecte a chaque fois.
Ce qui met un temps de plus en plus long pour afficher une nouvelle page.
DEBUG - Setting up data source.mardi 10 avril 2012 9h 12 '54''
DEBUG - Setting up data source.mardi 10 avril 2012 9h 12 '56''
DEBUG - Setting up data source.mardi 10 avril 2012 9h 12 '56''
DEBUG - Setting up data source.mardi 10 avril 2012 9h 12 '57''

Entre les 4 requêtes j'ai perdu 4 secondes.
Lorsque j'exécute 20 requêtes, je met plus de 2 minutes pour afficher la page.

Je suis sur qu'il ne récupère pas le pool de connexion, et qu'il se reconnecte a chaque requête.

Voici mon code:
Toutes mes requêtes sont organisé de cette manière:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
public int id_max() {
		// TODO Auto-generated method stub
		connect= JdbcConnector.getInstance();
		try {
			try {
				prepare = this.connect.prepareStatement("SELECT id FROM achat_articles ORDER BY id DESC LIMIT 0, 1");
				//On exécute la requête
				resultat = prepare.executeQuery();
 
				if(resultat.first())
				id_max=resultat.getInt("id")+1;
 
			} catch (SQLException e) {
				e.printStackTrace();
			} finally {
				if (resultat != null) {
					resultat.close();
				}
				if (prepare != null) {
					prepare.close();
				}  
				if (connect != null) {
					connect.close();
				} 
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return id_max;
	}
Voici ma méthode de connexion avec C3P0:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
public class JdbcConnector {
	static Logger logger = Logger.getLogger("JdbcConnector.class");
	private static Connection connect;
	private static DataSource ds;
 
	/**
         * Méthode qui va retourner notre instance
         * et la créer si elle n'existe pas...
         * @return
         */
	public static Connection getInstance(){
		try {
			if(connect == null || connect.isClosed()){
					//On regarde les préférences:
					Serializer<Preferences> preferences = new Serializer<Preferences>(new File("file/Pito.lic"));
					preferences.lectureserialize();
					Serializer<Licence> licence = new Serializer<Licence>(new File("file/sack.lic"));
					licence.lectureserialize();
					String serveur=(licence.getObject()!=null && licence.getObject().getType_licence().equals("normal"))?"localhost":preferences.getObject().getServeur();
					if(preferences.getFile().length() > 0 && preferences.getObject().isConnection_bdd()){
						String base = preferences.getObject().getBase();
						String utilisteur=preferences.getObject().getUtilisateur();
						String passe=preferences.getObject().getPassword();
						Datetime date = new Datetime();
						System.out.println("Setting up data source."+date.getDateHeureString());
						try {
							DataSource unpooled = DataSources.unpooledDataSource("jdbc:mysql://"+serveur+"/"+base, utilisteur, passe);
							DataSource pooled = DataSources.pooledDataSource( unpooled );
							connect= pooled.getConnection();
						} catch (Exception e) {
							e.printStackTrace();
							JOptionPane.showMessageDialog(null, e.getMessage(), "ERREUR DE CONNEXION ! ", JOptionPane.ERROR_MESSAGE);
						}
				        System.out.println("Done.");
					}
					else{
						connect=null;
						JOptionPane.showMessageDialog(null, "Impossible de se connecter!", "ERREUR DE CONNEXION ! ", JOptionPane.ERROR_MESSAGE);
					}
			}
		} catch (HeadlessException e) {
			e.printStackTrace();
			JOptionPane.showMessageDialog(null, e.getMessage(), "ERREUR DE CONNEXION ! ", JOptionPane.ERROR_MESSAGE);
		} catch (SQLException e) {
			e.printStackTrace();
			JOptionPane.showMessageDialog(null, e.getMessage(), "ERREUR DE CONNEXION ! ", JOptionPane.ERROR_MESSAGE);
		}
		return connect;	
	}
Merci pour votre aide