import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.ResourceBundle;
import Database.DatabaseConnection;
import SQLQuery.Teacher.TeacherListSql;
import com.allClass.Model.TeacherListInfo;
public class LoadAction{ //public class LoadAction{ N.B: Not add field error message
// use for log in username and passward kaniz
private String userName; //globalydeclare for '" + userName + "'
private String password; //globalydeclare for '" + password + "'
/ ************************ Above variable set get *********************************
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
// ************************ Above variable set get *********************************
//START Login code **************
public String enterLogInPage(){
//int usrname = 0;
String usrname = "";
boolean fg = true;
con = dbc.connectDB();
if (con == null) {
fg = false;
}
if (fg) {
try {
st = con.createStatement();
/* query = "select USER_NAME from LOGIN_USERS where USER_NAME='" + userName + "' "
+ " and PASSWORD='" + password + "'";*/
// query = "select USER_NAME from LOGIN_USERS where USER_NAME='" + userName + "' and PASSWORD='" + password + "'";
query = "select USER_ID from login_users where USER_ID='" + userName + "' and PASSWORD='" + password + "'";
System.out.println(query);
rs = st.executeQuery(query);
while (rs.next()) {
//usrname = rs.getRow();
usrname = rs.getString("USER_ID");
}
} catch (SQLException sq) {
sq.printStackTrace();
} finally {
try {
if (rs != null) {
rs.close();
}
con.close();
} catch (SQLException ex) {
ex.printStackTrace();
}
}
}
if (!usrname.isEmpty()) {
return "enterLogInPage";
}else{
return "enterLogInPageFail";
}
//return "enterLogInPageFail";
}
//END Log in code ***************
if (!usrname.isEmpty()) {
return "enterLogInPage";
} }else{
return "enterLogInPageFail";
}
//return "enterLogInPageFail";
}
######################################################################################
######################################################################################
Add error message
.................
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.ResourceBundle;
import Database.DatabaseConnection;
import SQLQuery.Teacher.TeacherListSql;
import com.allClass.Model.TeacherListInfo;
import com.opensymphony.xwork2.ActionContext; //public class LoadAction{ N.B: add field error message
import com.opensymphony.xwork2.ActionSupport;//public class LoadAction{ N.B: add field error message
public class LoadAction extends ActionSupport { //public class LoadAction{ N.B: Not add field error message
if (usrname>0) {
return "enterLogInPage";
}else{
addFieldError("logMsg","Your Account Is Not active!!"); //N.B: After add field error message
return "enterLogInPageFail";
}
}
And jsp page change
--------------------
<td colspan="5" style="text-align:center;">
<b id="" style="color:red" class="">
<s:fielderror>
<s:param value="logMsg"/>
</s:fielderror>
</b>
</td>
Raph:
......
In jsp page
============
<s:fielderror>
<s:param value="logMsg"/>
</s:fielderror>
In action class
================
extends ActionSupport
addFieldError("logMsg","Your Account Is Not active!!");
return "loginFail";
in Struts.xml page
==================
<result name="loginFail">LoginHome.jsp</result>
######################################################################################
######################################################################################
n.B: select USER_ID from login_users where USER_ID='sohag' and PASSWORD='sohag'
If use this query then output show just USER_ID
DO run Query :
**************
select * from login_users where USER_ID='sohag' and PASSWORD='sohag'
select USER_ID from login_users where USER_ID='sohag' and PASSWORD='sohag'
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Step 1 : At First run(F9) this script in toad editor desire schema then make table name login_users ( blank table that means this table coloumn have no data )
----------------------------------------------------------------------------------------------------------------------------
DROP TABLE BANBEIS_TEACHER_CENSUS.LOGIN_USERS CASCADE CONSTRAINTS;
CREATE TABLE BANBEIS_TEACHER_CENSUS.LOGIN_USERS
(
USER_ID VARCHAR2(10 BYTE),
USER_NAME VARCHAR2(100 BYTE),
LOGIN_NAME VARCHAR2(10 BYTE),
PASSWORD VARCHAR2(10 BYTE),
PRIVILEGE_TYPE VARCHAR2(1 BYTE),
GROUP_ID VARCHAR2(10 BYTE),
ENTERED_BY VARCHAR2(10 BYTE),
ENTRY_TIMESTAMP DATE,
LAST_UPDATED_BY VARCHAR2(10 BYTE),
LAST_UPDATED_TIMESTAMP DATE,
USER_TYPE VARCHAR2(1 BYTE),
DISTRICT_ID VARCHAR2(4 BYTE)
)
TABLESPACE USERS
PCTUSED 0
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 64K
NEXT 1M
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0
BUFFER_POOL DEFAULT
)
LOGGING
NOCOMPRESS
NOCACHE
NOPARALLEL
MONITORING;
---------------------------------------------------------------------
Step 2 :Now data put in table coloumn, so run this data(F9)
---------------------------------------------------------------------
SET DEFINE OFF;
Insert into LOGIN_USERS
(USER_ID, USER_NAME, LOGIN_NAME, PASSWORD, PRIVILEGE_TYPE,
GROUP_ID, ENTERED_BY, ENTRY_TIMESTAMP, LAST_UPDATED_BY, LAST_UPDATED_TIMESTAMP,
USER_TYPE, DISTRICT_ID)
Values
('sohag', 'sohag', 'sohag', 'sohag', 'U',
NULL, NULL, NULL, NULL, NULL,
NULL, NULL);
COMMIT;
--------------------------------------------------------
only run : Top line and last line is out of run(F9)
--------------------------------------------------------
Insert into LOGIN_USERS
(USER_ID, USER_NAME, LOGIN_NAME, PASSWORD, PRIVILEGE_TYPE,
GROUP_ID, ENTERED_BY, ENTRY_TIMESTAMP, LAST_UPDATED_BY, LAST_UPDATED_TIMESTAMP,
USER_TYPE, DISTRICT_ID)
Values
('sohag', 'sohag', 'sohag', 'sohag', 'U',
NULL, NULL, NULL, NULL, NULL,
NULL, NULL);
-----------------------------------------------------------------------------
Step 1 and Step 2 out put is show as image Db_logIn_img 1
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.ResourceBundle;
import Database.DatabaseConnection;
import SQLQuery.Teacher.TeacherListSql;
import com.allClass.Model.TeacherListInfo;
public class LoadAction{ //public class LoadAction{ N.B: Not add field error message
// use for log in username and passward kaniz
private String userName; //globalydeclare for '" + userName + "'
private String password; //globalydeclare for '" + password + "'
/ ************************ Above variable set get *********************************
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
// ************************ Above variable set get *********************************
//START Login code **************
public String enterLogInPage(){
//int usrname = 0;
String usrname = "";
boolean fg = true;
con = dbc.connectDB();
if (con == null) {
fg = false;
}
if (fg) {
try {
st = con.createStatement();
/* query = "select USER_NAME from LOGIN_USERS where USER_NAME='" + userName + "' "
+ " and PASSWORD='" + password + "'";*/
// query = "select USER_NAME from LOGIN_USERS where USER_NAME='" + userName + "' and PASSWORD='" + password + "'";
query = "select USER_ID from login_users where USER_ID='" + userName + "' and PASSWORD='" + password + "'";
System.out.println(query);
rs = st.executeQuery(query);
while (rs.next()) {
//usrname = rs.getRow();
usrname = rs.getString("USER_ID");
}
} catch (SQLException sq) {
sq.printStackTrace();
} finally {
try {
if (rs != null) {
rs.close();
}
con.close();
} catch (SQLException ex) {
ex.printStackTrace();
}
}
}
if (!usrname.isEmpty()) {
return "enterLogInPage";
}else{
return "enterLogInPageFail";
}
//return "enterLogInPageFail";
}
//END Log in code ***************
if (!usrname.isEmpty()) {
return "enterLogInPage";
} }else{
return "enterLogInPageFail";
}
//return "enterLogInPageFail";
}
######################################################################################
######################################################################################
Add error message
.................
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.ResourceBundle;
import Database.DatabaseConnection;
import SQLQuery.Teacher.TeacherListSql;
import com.allClass.Model.TeacherListInfo;
import com.opensymphony.xwork2.ActionContext; //public class LoadAction{ N.B: add field error message
import com.opensymphony.xwork2.ActionSupport;//public class LoadAction{ N.B: add field error message
public class LoadAction extends ActionSupport { //public class LoadAction{ N.B: Not add field error message
if (usrname>0) {
return "enterLogInPage";
}else{
addFieldError("logMsg","Your Account Is Not active!!"); //N.B: After add field error message
return "enterLogInPageFail";
}
}
And jsp page change
--------------------
<td colspan="5" style="text-align:center;">
<b id="" style="color:red" class="">
<s:fielderror>
<s:param value="logMsg"/>
</s:fielderror>
</b>
</td>
Raph:
......
In jsp page
============
<s:fielderror>
<s:param value="logMsg"/>
</s:fielderror>
In action class
================
extends ActionSupport
addFieldError("logMsg","Your Account Is Not active!!");
return "loginFail";
in Struts.xml page
==================
<result name="loginFail">LoginHome.jsp</result>
######################################################################################
######################################################################################
n.B: select USER_ID from login_users where USER_ID='sohag' and PASSWORD='sohag'
If use this query then output show just USER_ID
DO run Query :
**************
select * from login_users where USER_ID='sohag' and PASSWORD='sohag'
select USER_ID from login_users where USER_ID='sohag' and PASSWORD='sohag'
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Step 1 : At First run(F9) this script in toad editor desire schema then make table name login_users ( blank table that means this table coloumn have no data )
----------------------------------------------------------------------------------------------------------------------------
DROP TABLE BANBEIS_TEACHER_CENSUS.LOGIN_USERS CASCADE CONSTRAINTS;
CREATE TABLE BANBEIS_TEACHER_CENSUS.LOGIN_USERS
(
USER_ID VARCHAR2(10 BYTE),
USER_NAME VARCHAR2(100 BYTE),
LOGIN_NAME VARCHAR2(10 BYTE),
PASSWORD VARCHAR2(10 BYTE),
PRIVILEGE_TYPE VARCHAR2(1 BYTE),
GROUP_ID VARCHAR2(10 BYTE),
ENTERED_BY VARCHAR2(10 BYTE),
ENTRY_TIMESTAMP DATE,
LAST_UPDATED_BY VARCHAR2(10 BYTE),
LAST_UPDATED_TIMESTAMP DATE,
USER_TYPE VARCHAR2(1 BYTE),
DISTRICT_ID VARCHAR2(4 BYTE)
)
TABLESPACE USERS
PCTUSED 0
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 64K
NEXT 1M
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0
BUFFER_POOL DEFAULT
)
LOGGING
NOCOMPRESS
NOCACHE
NOPARALLEL
MONITORING;
---------------------------------------------------------------------
Step 2 :Now data put in table coloumn, so run this data(F9)
---------------------------------------------------------------------
SET DEFINE OFF;
Insert into LOGIN_USERS
(USER_ID, USER_NAME, LOGIN_NAME, PASSWORD, PRIVILEGE_TYPE,
GROUP_ID, ENTERED_BY, ENTRY_TIMESTAMP, LAST_UPDATED_BY, LAST_UPDATED_TIMESTAMP,
USER_TYPE, DISTRICT_ID)
Values
('sohag', 'sohag', 'sohag', 'sohag', 'U',
NULL, NULL, NULL, NULL, NULL,
NULL, NULL);
COMMIT;
--------------------------------------------------------
only run : Top line and last line is out of run(F9)
--------------------------------------------------------
Insert into LOGIN_USERS
(USER_ID, USER_NAME, LOGIN_NAME, PASSWORD, PRIVILEGE_TYPE,
GROUP_ID, ENTERED_BY, ENTRY_TIMESTAMP, LAST_UPDATED_BY, LAST_UPDATED_TIMESTAMP,
USER_TYPE, DISTRICT_ID)
Values
('sohag', 'sohag', 'sohag', 'sohag', 'U',
NULL, NULL, NULL, NULL, NULL,
NULL, NULL);
-----------------------------------------------------------------------------
Step 1 and Step 2 out put is show as image Db_logIn_img 1
img 2 :
No comments:
Post a Comment