i want to know about the jdbc how i can valid a login page ?
thanks
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sazid MauhammadPosted Feb 4, 2013, 1:50 PM
and after that you should
write coding in .java file that i add in jar file you can see this one
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class DB {
/**
* @param args
*/
public static void main(String[] args) {
try {
String name="sonal";
String pass="asd";
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/login","root","admin");
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select password from login where userName ='"+name+"' ");
if(rs.next())
{
String temp_pass=rs.getString(1);
if(temp_pass.endsWith(pass))
{
System.out.println("Welcome "+name+" password is - "+pass);
}
else
{
System.out.println("Wrong Password");
}
}
else {
System.out.println("Invalid User");
}
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
this coding is use only for login database in mysql
umme salmaPosted Jan 24, 2013, 3:34 AM
Satyapriya NayakPosted Jan 24, 2013, 3:32 AM
http://www.c-sharpcorner.com/UploadFile/73d82f/database-connectivity-and-validation-of-data-from-oracle-dat/