rjohn5854's Profile
Reputation: 3
Apprentice
- Group:
- Active Members
- Active Posts:
- 171 (0.29 per day)
- Joined:
- 04-October 11
- Profile Views:
- 1,716
- Last Active:
Feb 26 2013 11:38 AM- Currently:
- Offline
Previous Fields
- Country:
- Who Cares
- OS Preference:
- Mac
- Favorite Browser:
- Chrome
- Favorite Processor:
- Intel
- Favorite Gaming Platform:
- Who Cares
- Your Car:
- Who Cares
- Dream Kudos:
- 0
Posts I've Made
-
In Topic: How to get the corresponding password using the given Email id
Posted 26 Feb 2013
No clue, I fixed the logic. Now, it's returning the password from the database. But, I still feel the program logic can get a lot better than this one.
Any clue, How I can write a more efficient logic ? making use the User class?
package com.rony.forgotpass; public class ForgotPass { public static void main(String[] args) { String password = (String) Forgotit.forgotpass("lin@yahoo.co.in"); System.out.println(password); } }
package com.rony.forgotpass; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; public class Forgotit { static Connection conn = null; static PreparedStatement ps = null; static ResultSet rs = null; public static String forgotpass(String email) { String sql = "SELECT password FROM User WHERE email='" + email + "'"; try { conn = DBUtil.getConnection(); if (conn != null) { ps = conn.prepareStatement(sql); rs = ps.executeQuery(); while (rs.next()) { String password = rs.getString("password"); return password; } } } catch (SQLException e) { e.printStackTrace(); } finally { DBUtil.closeConnection(); } return null; } }
package com.rony.forgotpass; public class User { private String forgotEmail; public String getForgotEmail() { return forgotEmail; } public void setForgotEmail(String email) { this.forgotEmail = email; } } -
In Topic: Error displaying value in the console.
Posted 19 Dec 2012
Thank You... it worked.... -
In Topic: Confusing with Constructors and Class being used a variable.
Posted 5 Nov 2012
Ohh ok... Thanks -
In Topic: Confusing with Constructors and Class being used a variable.
Posted 5 Nov 2012
Yep, thats what I was doing too... I will have to look more into the efficient way to doing things. Is there a "technical term" for using the Point class constructor in another class? -
In Topic: Confusing with Constructors and Class being used a variable.
Posted 5 Nov 2012
Ahh, that's what I was going to do then I saw this piece of code. So both ways can work but this is more efficient.
My Information
- Member Title:
- D.I.C Head
- Age:
- Age Unknown
- Birthday:
- Birthday Unknown
- Gender:
-
- Years Programming:
- 1
- Programming Languages:
- Mainily work on Java/J2EE and Front-end stuff.
Contact Information
- E-mail:
- Private
Friends
|
|


Find Topics
Find Posts
View Reputation Given


|
Comments
rjohn5854 has no profile comments yet. Why not say hello?