hi friends,

i was trying one java program, which gets the username and password from the user and has to check them if they r present in the database (MySQL) and has to give the result as soon as the OK button has been clicked..

i've created the GUI interface using eclipse and database in MySQL. My prob is that, i want to grab the text from the both text boxes, and have to search in MySQL with the texts typed in the text boxes.

i've used 3 classes, one for  getting n setting the user id and password to MySQL, another one is for connecting the java and MySQL and the final is for GUI..

--> this is a function which i used in the 2nd class.. here, i pass the 3rd class's object to this function

public boolean UsrAuthPw(UsrVerf uv){
boolean status = false;
Connection con = getconnect();
Statement s = con.createStatement();
String s1 = uv.t1.getText();
String s2 = uv.t2.getText();
ResultSet rs = s.executeQuery("SELECT UserId, Password from usrauth where UserId = ' "+s1+" ' and Password =  ' "+s2+"' ");
System.out.println("UserId = '"+s1+"' and Password = '"+s2+"");
while (rs.next()){
status = true;
catch(java.sql.SQLException sqlexcp){
System.out.println("SQL Exception");
status = false;
return status;

--> this is the main function of the 3rd class..

public static void main(String args[]){
JFrame frame = new JFrame("User Authentication");
UsrVerf uv = new UsrVerf();
UsrConn uc = new UsrConn();
boolean status = false;

if (status == true){
}else {


--> this wat i gave for the action to be done as soon as, the button is pressed..

public void actionPerformed(ActionEvent e){
String s1 = t1.getText();
String s2 = t2.getText();
if (s1.equals(s2)){
l3.setText("Both are same");
} else {

when i run the prog, i'm getting the GUI and if i give the correct user id and password, the output is like this..

UserId = '   ' and Password = '  '

am i correct with this one..

can anyone get me clear..


Like it on Facebook, Tweet it or share this article on other bookmarking websites.

Comments (0)

There are no comments posted here yet

What is the best way to spend a holiday?

No answer selected. Please try again.
Please select either existing option or enter your own, however not both.
Please select minimum 0 answer(s) and maximum 8 answer(s).
[{"id":"23123","title":"Read Books","votes":"14","type":"x","order":"1","pct":17.28,"resources":[]},{"id":"23124","title":"Spend time on social networking sites","votes":"4","type":"x","order":"2","pct":4.94,"resources":[]},{"id":"23125","title":"Talk to friends","votes":"7","type":"x","order":"3","pct":8.64,"resources":[]},{"id":"23126","title":"Research any career related courses\/jobs\/business","votes":"6","type":"x","order":"4","pct":7.41,"resources":[]},{"id":"23127","title":"Play any sport outside with friends","votes":"16","type":"x","order":"5","pct":19.75,"resources":[]},{"id":"23128","title":"Watch T.V","votes":"3","type":"x","order":"6","pct":3.7,"resources":[]},{"id":"23129","title":"Go for an outing to any resort\/Park","votes":"25","type":"x","order":"7","pct":30.86,"resources":[]},{"id":"23130","title":"Sleep","votes":"6","type":"x","order":"8","pct":7.41,"resources":[]}] ["#ff5b00","#4ac0f2","#b80028","#eef66c","#60bb22","#b96a9a","#62c2cc"] ["rgba(255,91,0,0.7)","rgba(74,192,242,0.7)","rgba(184,0,40,0.7)","rgba(238,246,108,0.7)","rgba(96,187,34,0.7)","rgba(185,106,154,0.7)","rgba(98,194,204,0.7)"] 350
bottom 200
No married couple wants to end up getting divorced. It is not like they have planned for it. They try to put up with their partners for as long as they
Due to our modern lifestyle, we feel that digestion related disorders are a common problem. Thus, we neither give importance to them nor seek any help
The bond of marriage brings the two people together. Initially, everything may seem okay and both of them slowly start discovering each other in the journey.
Why to choose Java? In the computer market, being able to use Java is a crucial knowledge. Java is a development terminology used to build compelling
DATABASE CONNECTIVITY This articles explains the need of database connectivity, the way it is achieved through Java using the JDBC(java database connectivity)
  Write your first simple java program.   First of all we need is a placewhere we can write your Java code. All Java programs are written using
Array of objects in Java Arrays are defined as block of continous memory locations which are arranged in one after another. Elements of the Array can
Synchronized block is alternative mechanism for "synchronized" methods.If we inherihate the non synchronized blocks either from base class or interface