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
| public String getConnection() {
String wsuser = this.user;
String wspswd = this.pswd;
setNow(dateGetter());
log.log(Level.WARN, "message de test");
int cpt = 0;
String query = "SELECT COUNT(*) FROM WSUSER WHERE IDENTIFIANT = '"
+ wsuser + "' AND PASSWD = '" + wspswd + "'";
// System.out.println(query);
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
} catch (ClassNotFoundException e) {
System.out.println("driver non etabli" + e);
}
Connection con = null;
String s = null;
try {
con = DriverManager.getConnection("jdbc:odbc:orcl1", "amira",
"amira");
Statement stmt = null;
ResultSet rset = null;
stmt = con.createStatement();
rset = stmt.executeQuery(query);
while (rset.next()) {
s = rset.getString(1);
}
con.close();
cpt = Integer.parseInt(s);
} catch (SQLException e) {
System.out.println("ERREUR SQL: " + e.getMessage());
System.out.print(cpt);
}
if (cpt == 0) {
return "erreur";
} else {
return "welcome";
}
} |
Partager