Bonjour,
Le code suivant est le code généré automatiquement par netbeans qd on créée une DesktopApplication. J'ai ajouté une méthode pour établir une connexion à une db. La connexion ne s'établit pas, la tentative de connexion reste bloquante. Cette méthode de connexion fonctionne, je l'ai testé séparément. Après une recherche, j'ai lu qu'il fallait mettre la ligne de code suivante: ProxySelector.getDefault();
avant le launch (sans plus d'explications)
et cela fonctionne en effet. Quelqu'un saurait-il m'expliquer pourquoi?
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 public class DesktopApplication1 extends SingleFrameApplication { /** * At startup create and show the main frame of the application. */ @Override protected void startup() { show(new DesktopApplication1View(this)); } /** * This method is to initialize the specified window by injecting resources. * Windows shown in our application come fully initialized from the GUI * builder, so this additional configuration is not needed. */ @Override protected void configureWindow(java.awt.Window root) { } /** * A convenient static getter for the application instance. * @return the instance of DesktopApplication1 */ public static DesktopApplication1 getApplication() { return Application.getInstance(DesktopApplication1.class); } /** * Main method launching the application. */ public static void main(String[] args) { launch(DesktopApplication1.class, args); } }
Partager