I’m developing a simple login form with JSF, Jboss and Oracle. The problem is that I have a problem when I make this SQL statement:
SQL_Statement = "SELECT Passwd from USERS WHERE Username = ?";
PreparedStatement passwordQuery = conn.prepareStatement(SQL_Statement);
passwordQuery.setString(1, userToCheck);
ResultSet result = passwordQuery.executeQuery();
if(result.next()){
storedPassword = result.getString("Passwd");
This is the table structure in oracle:
CREATE TABLE "USERS"(
"UserId" Integer NOT NULL,
"GroupId" Integer,
"SpecialNumber" Varchar2(60 ),
"Username" Varchar2(50 ),
"Passwd" Varchar2(50 ),
"DateToChangePasswd" Date,
"Address" Varchar2(60 ),
"StateRegion" Varchar2(50 ),
"Country" Varchar2(50 ),
"AdminStatus" Varchar2(30 ),
"Telephone" Varchar2(50 ),
"DateUserAdded" Date,
"UserExpireDate" Date,
"DateUserLocked" Char(20 ),
"City" Varchar2(50 ),
"EMail" Varchar2(50 ),
"Comment" Clob
)
Maybe the SQL statement is not valid? Can you point me where is the problem?
I think this problem is caused by the double quotes used to declare the columns in the table. Enclosing the column names in double quotes make them case-sensitive. And your select query automatically transforms Passwd into PASSWD. So the column can’t be found.
Change your create table query to
This way, column names will be case insensitive.
See http://docs.oracle.com/cd/B19306_01/server.102/b14200/sql_elements008.htm for more information.