User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 426,425 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,443 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Java advertiser: Lunarpages Java Web Hosting

Login Form verification MySQL "Java"

Join Date: Dec 2007
Location: Greece
Posts: 551
Reputation: javaAddict will become famous soon enough javaAddict will become famous soon enough 
Rep Power: 3
Solved Threads: 63
javaAddict's Avatar
javaAddict javaAddict is offline Offline
Posting Pro

Re: Login Form verification MySQL "Java"

  #8  
Apr 19th, 2008
Since you are using PreparedStatement and not the simple Statement then change this:

pstat = conn.prepareStatement("select username,password from user where username='"+ username + "' and password = '"+password+ "'"); to this:

pstat = conn.prepareStatement(
"select username,password from user where username=? and password = ?"
);

After you get the resultSet and call its methods(rs.next()) and before you break, you must close everything:
rs.close();
pstat.close();
conn.close(); Note: if you want to run a query again, you must reopen the connection, so it would be better if you put the code that opens it in some method so you can call it whenever you want to open a connection

Next time besides the code, post the errors you get and at which line
I AM the 12th CYLON
Reply With Quote  
All times are GMT -4. The time now is 2:18 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC