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
|
public void windowOpened(WindowEvent evt){
String url = "sqlserver://localhost:1433";
try
{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null,"Impossible de ce connecter au serveur","Erreur de l'application",JOptionPane.ERROR_MESSAGE);
Toolkit.getDefaultToolkit().beep();
}
try
{
Connection con = DriverManager.getConnection(url,"administrateur","");
Statement st = con.createStatement();
ResultSet QueryNbssd = st.executeQuery("SELECT COUNT orientation FROM personne WHERE orientation = 'solidarite developpement'");
while(QueryNbssd.next()){
int sqintssd = QueryNbssd.getInt(1);
String sqtextsd = Integer.toString(sqintssd);
textssd.setText(sqtextsd);
}
}
{
JOptionPane.showMessageDialog(null,"DOnnées inaccessible");
}
} |
Partager