Hi,
In this program, i have established the connection and it even works. i get a value from the table and checked it with the given value . if both r same, i have to assign that value to a string. But if i try assigning the value to a string variable, it goes out of the try statement to the catch statement..can u please help me what's wrong and why its not working....than k you.
i have given the print statement inside the if condition..its working. but the variable assignment is not working.
In this program, i have established the connection and it even works. i get a value from the table and checked it with the given value . if both r same, i have to assign that value to a string. But if i try assigning the value to a string variable, it goes out of the try statement to the catch statement..can u please help me what's wrong and why its not working....than k you.
i have given the print statement inside the if condition..its working. but the variable assignment is not working.
Code:
try
{
login_name=usert.getText().trim();
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
String url = "jdbc:odbc:sakthi";
con = (Connection)DriverManager.getConnection(url,"sakthi","");
Statement stmt=con.createStatement();
System.out.println("Connection :"+con);
System.out.println("Connection is created!"+login_name);
String run=("select * from logg");
ResultSet rs=stmt.executeQuery(run);
while(rs.next())
{
if(rs.getString("user").trim().equalsIgnoreCase(login_name.trim()))
{
System.out.println("hello");
//uid=rs.getString("user");
// System.out.println(uid);
}
else
{
System.out.println(" bye");
}
}con.close();
}
catch(Exception s)
{
System.out.println("Doesn't establish the connection!");
System.exit(0);
}
}
Comment