How can one execute two queries at the same time using mysql and java? I am facing a problem with this login i created.the login works just fine.but when it works in a network if two different uses try to login at the same instance it doesn't work. users can log in individualy.is there a particular method two achieve this?
the code is as follows
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.security.MessageDigest;
import sun.misc.BASE64Encoder;
//import java.sql.ResultSet;
import java.sql.SQLException;
public class userauthentication {
public static String getuserauthentication(String x,String y){
String column="123",prio_no="0";
//String encrypted=password.encryptSha(x);
try{
DBFacede d=new DBFacede();
ResultSet r1 = d.fetch("SELECT a.Password FROM login a WHERE a.user_id='"+y+"'");
r1.last();
int rows = r1.getRow();
r1.beforeFirst();
for(int i=0;i<rows;i++){
if(r1.next()){
}
}
column=r1.getString("Password");
ResultSet r2 = d.fetch("SELECT a.Priority FROM login a WHERE a.user_id='"+y+"'");
r2.last();
int rows1 = r2.getRow();
r2.beforeFirst();
for(int i=0;i<rows1;i++){
if(r2.next()){
}
}
prio_no=r2.getString("Priority");
System.out.println(column+"**********");
}
catch (SQLException s){
System.out.println("SQL statement is not executed!");
}
//System.out.println(column);
if(column.equals(x)){
return prio_no;}
else {
return "0";
}
}