Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within JDBC and Relational Databases
Search Coderanch
Advance search
Google search
Register / Login
Win a copy of
Eclipse Collections Categorically: Level up your programming game
this week in the
Open Source Projects
forum!
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Tim Cooke
paul wheaton
Ron McLeod
Jeanne Boyarsky
Sheriffs:
Paul Clapham
Saloon Keepers:
Tim Holloway
Roland Mueller
Bartenders:
Forum:
JDBC and Relational Databases
using queries
Justin Fox
Ranch Hand
Posts: 802
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
i want to compare textfield input with values in the database, this is what i have so far.
public static class LoginListener implements ActionListener{ public void actionPerformed(ActionEvent event) { if(event.getSource() == login) { TYPE = users[userType.getSelectedIndex()]; if(TYPE.equals("Student")) { String userlogin = "'"+Sname.getText()+"'"; String userPass = "'"+SID.getText()+"'"; String whereClause = ("WHERE FName = "+userlogin +" AND "+"SID = "+userPass); try{ Statement statement = con.createStatement(); ResultSet rs = statement.executeQuery("SELECT FName FROM STUDENTS "+whereClause); while(rs.next()) { System.out.println(rs.getString("FName") + " "); } if(!rs.wasNull()) { LoginFrame.dispose(); Student.setVisible(true); } else { /*show dialog*/ System.out.println("user not found"); } rs.close(); statement.close(); }catch(SQLException sqle) { System.out.println("jdbc error: "+sqle); } } else { LoginFrame.dispose(); Admin.setVisible(true); } } } }
for some reason the wasnull isnt doing what i thought it would do...
Justin
You down with OOP? Yeah you know me!
Chad Clites
Ranch Hand
Posts: 134
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
What do you suppose wasNull() is supposed to do? What did you expect it to do?
So there I was, trapped in the jungle. And at the last minute, I was saved by this tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
To show the Error message at the login.jsp page using servlet
JList Problem
Error while using PreparedStatement
Returning an array of objects through a web service
Check if file Exists
More...