If you just want to check if the guy exist, you can do that :
(stat is a PreparedStatement)
PreparedStatment stat;
stat = con.prepareStatement("SELECT Nome,Password FROM Utenti where Nome
like ?");
stat.setString(1,userId);
rsStudente = stat.executeQuery();
if (rsStudente== null)
{
// the user is not found !
auth = false;
}
else
{
auth = true;
}
PS it's better to use a boolean for auth than a String !
-----Original Message-----
From: BERWART Thierry [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, September 26, 2000 11:21 AM
To: [EMAIL PROTECTED]
Subject: Re: ODBC problem
hello
rsStudente= stat.executeQuery("SELECT Nome FROM Utenti");
String nome = rsStudente.getString("Nome");
String passw = rsUser.getString("Password");
1. some database doen't support the get... (fieldname) try with the index!
2. it's impossible to get the password because you don't select it in the
query
-> solution
rsStudente= stat.executeQuery("SELECT Nome,Password FROM Utenti");
String nome = rsStudente.getString(1);
String passw = rsUser.getString(2);
Caution :
the password is perhaps in Hexa instead of a string !
bye bye
Thierry
-----Original Message-----
From: Elena Palanca [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, September 26, 2000 11:07 AM
To: [EMAIL PROTECTED]
Subject: ODBC problem
Hy,
I'm tried to connect in a servlet to an ACCESS database doing a select
operation and I have the following error:
[parseRequest]Errore 2:java.sql.SQLException: [Microsoft][ODBC Driver
Manager] Stato del cursore non valido. (Invalid Cursor State)
In the Access Table I have only a row with the field Nome and Password
My code is the following:
String userId = req.getParameter( "UserId" );
try{
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
Connection con = DriverManager.getConnection
("jdbc:odbc:Esami","","");
Statement stat= con.createStatement();
rsStudente= stat.executeQuery("SELECT Nome FROM Utenti");
String nome = rsStudente.getString("Nome");
String passw = rsUser.getString("Password");
if ((nome.equals(userId))) auth="true";
rsStudente.close();
stat.close();
}catch (Exception e) {
log( "[parseRequest]Errore 2:" + e.toString() );
}
Someone know what I'm doing wrong?
Thanks in advance
Elena
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html