Saturday, September 29, 2018

Sql சர்வர் 6 அடிப்படை நேர்முகத் தேர்வு வினாக்களும் விடைகளும்.


முதலில் 2 டேபிள்கள் உருவாக்க வேண்டும்.
1.Department
2.Employee

முதல் டேபிள்

 
இரண்டாவது டேபிள்



இரண்டு டேபிளுக்கும் Dept_Id காலத்தில் ஃபாரின்கீ ரிலேசன் செய்து கொள்ளவும்
.கேள்வி 1
அதிக சம்பளம் வாங்குவோர் விபரம்.
விடை
select * from Employee where Emp_Salary=(select MAX (Emp_Salary) from Employee)
2. அதிக பட்ச சம்பளம்.
select MAX (Emp_Salary) from Employee


3. இரண்டாவது அதிக பட்ச சம்பளம்.
விடை.
select MAX (Emp_Salary) from Employee where Emp_Salary not in(select MAX (Emp_Salary) from Employee)
4.Emp id 2003 மற்றும் 2008 க்கிடையே யானோர் விவரம்.
விடை.
select * from Employee where Emp_Id>2003 and Emp_Id<2008
5. அதிகபட்ச சம்பளம் வாங்குவோர் விவரம். Dept name உடன்.
விடை
select e.Emp_Id, e.Emp_Name, e.Emp_salary, d.Dept_Name
from Employee e inner join Department d on(e.Dept_Id=d.Dept_Id)
where Emp_salary=(select max(Emp_salary) from Employee)
6. .  ஒவ்வொரு டிபார்ட் மெண்டிலும் அதிகபட்ச சம்பளம் வாங்குவோர் விவரம். Dept name உடன்.
விடை

select e.Emp_Id, e.Emp_Name, e.Emp_salary, d.Dept_Name
from Employee e inner join Department d on(e.Dept_Id=d.Dept_Id)
where Emp_salary in(select max(Emp_salary) from Employee group by Dept_Id)

நன்றி
முத்து கார்த்திகேயன், மதுரை.

ads Udanz

Friday, September 28, 2018

கோரல் டிராவில் ட்ரான்ஸ்ஃபர்மேஷன்.



Transformations கட்டளையானது Arrange மெனுவில் முதலில் உள்ளது.அதில் மொத்தம் 5 கட்டளைகள் உள்ளன.
அவை
1.   Position
2.   Rotate
3.   Scale
4.   Size
5.   Skew

1.position.
முதலில் 50mm*50 mm கொண்ட சதுரம் ஒன்றை வரைந்து கொள்ளவும்.. பிற்கு அரேஞ்ச் மெனுவில் transformations என்பதில் position என்பதை கிளிக் செய்யவும்.
பின் வரும் விண்டோ வரும்.

அதில் h என்பதில் 50, v என்பதில் 50 கொடுக்கவும்.
Copies என்பதில் 2 என கொடுக்கவும்.
பின்னர் Apply பட்டனை கிளிக் செய்யவும்.
பின் வரும் தோற்றம் இருக்கும்.
அதாவது சதுரம் ஆனது ஹரிசாண்டல் ஆக 50mmம் வெர்டிகல் ஆக 50 mmம் நகர்ந்து 2 காப்பிகள் உருவாகியிருக்கும்.
2. rotate
முதலில் 15mm*90mm கொண்ட நீள் வட்டம் ஒன்றை வரைந்து கொள்ளவும்.பின்பு அதை செலெக்ட் செய்து கொள்ளவும் அரேஞ்ச் மெனுவில்
tranformations என்பதில் rotate என்பதைசெலெக்ட்செய்யவும்.
இதில் angle என்பதில் 30 டிகிரி கொடுக்கவும். Copies என்பதில் 5 என கொடுக்கவும். இப்பொழுது apply பட்டனை கிளிக் செய்யவும்.



மேல் உள்ளவாறு விண்டோ இருக்கும். அதாவது இந்த ஆப்சன் ஆனது 0-360 வரையில் ஏதாவது ஒரு ஆங்கிளுக்கு ரொடேட் செய்ய பயன்படுகின்றது.
3.scale
.ஆப்ஜெக்ட் ஒன்று வரைந்து கொண்டு அதை சத வீதத்தில் (உ-ம் 120%) பெரிதாக்கவோ அல்லது குறைத்துக் கொள்ளவோ இந்த ஆப்சன் பயன்படுகின்றது.
அரேஞ்ச் மெனுவில் transformation என்பதில் scale என்பதை தேர்ந்தெடுக்கவும்.
h,z என்ற் இரண்டிலுமே 120 என கொடுக்கவும். Copies என்பதில் 3 எனக் கொடுத்து அப்ளை பட்டனை கிளிக் செய்யவும்.

Size:
இதில் சரியான அளவு கொடுத்து அதற்கேற்றாற் போல் மாற்றிக் கொள்ள இது பயன்படுகின்றது..
 முதலில் சதுரம் அல்லது செவ்வகம் வரைந்து  கொண்டு இதில் அரேஞ்ச் மெனுவில் transformations என்பதில் சிழெ செலெக்ட் செய்து அதில் h,z ஆகியவற்றிக்கு சர்இயான அளவைக் குறிப்பிட்டு அப்ளை பட்டனை கிளிக் செய்யவும்.
5.skew:
இதில் ஒரு டெக்ஸ்ட் ஒன்றை டைப் செய்து கொள்ளவும்.பிறகு arrange மெனுவில் transformations என்பதில் skew செலெக்ட் செய்யவும்.

இதில் h என்பதில் 30 டிகிரியும், v என்பதில் 0-வும் கொடுக்கவும்.இப்போது அப்ளை பட்டனை கிளிக் செய்யவும்.

இப்பொழுது டெக்ஸ்ட் 30 டிகிரி சாய்வாக இருக்கும்..

-நன்றி
முத்து கார்த்திகேயன்,மதுரை.
ads Udanz

Wednesday, September 26, 2018

ஜாவா சர்வர் பேஜஸ் லாக் இன் மற்று லாக் அவுட்



இந்த கட்டுரையில் JSP பயன்படுத்தி எவ்வாறு லாக் இன் மற்றும் லாக் அவுட் ஃபார்ம் உருவாக்கலாம் என்பது குறித்து பார்ப்போம். பயனர் இன்புட் கொடுக்கும் போது அது டேட்டா பேஸுடன் தொடர்பு கொண்டு அதை வேலிடேட் செய்கின்றது. எனவே முதலில் டேட்டா பேஸில் நாம் ஏற்கனவே மதிப்புகள் கொடுத்திருக்க வேண்டும்.
இங்கு JSP implicit session பயன்படுத்தி இருக்கின்றது. setAtttribute பயன்படுத்தி session attribute மதிப்பை set செய்கின்றது. getAttribute பயன்படுத்தி session attribute மதிப்பை get செய்கின்றது. Session.invlaidateபயன்படுத்தி செஸனை முடிக்கின்றது.                           
மற்ற பக்கங்கள்  home.jsp, login.jsp, logout.jsp, welcome.jsp, error.jsp மற்றும் index.jsp ஆகியவற்றையும் உருவாக்குவோம்.
கீழே உள்ள படத்தில்  டேட்டா பேசில் யூசர் நேம், பாஸ்வேர்டு கொடுக்கப்பட்டுள்ளது.

home.jsp
ecplise எடிட்டரில் கீழே உள்ள படத்தில் உள்ளது போல் கோடிங் இருக்கும்.ஹோம் பேஜ் ஆனது யூசர் நேம் பாஸ் வேர்டு கொடுக்கும் கோடிங்கை கொண்டுள்ளது.
 
<%@ page import="java.sql.*" %>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<title>Home</title>

</head>

<body>

<%

Connection con= null;

PreparedStatement ps = null;

ResultSet rs = null;



String driverName = "com.mysql.jdbc.Driver";

String url = "jdbc:mysql://localhost:3306/record";

String user = "root";

String password = "root";



String sql = "select usertype from userdetail";



try {

Class.forName(driverName);

con = DriverManager.getConnection(url, user, password);

ps = con.prepareStatement(sql);

rs = ps.executeQuery();

%>

<form method="post" action="login.jsp">

<center><h2 style="color:green">JSP Login Example</h2></center>

<table border="1" align="center">

<tr>

<td>Enter Your Name :</td>

<td><input type="text" name="name"/></td>

</tr>

<tr>

<td>Enter Your Password :</td>

<td><input type="password" name="password"/></td>

</tr>

<tr>

<td>Select UserType</td>

<td><select name="usertype">

<option value="select">select</option>

<%

while(rs.next())

{

String usertype = rs.getString("usertype");

%>

<option value=<%=usertype%>><%=usertype%></option>

<%

}

}

catch(SQLException sqe)

{

out.println("home"+sqe);

}

%>

</select>

</td>

</tr>

<tr>

<td></td>

<td><input type="submit" value="submit"/></td>

</table>

</form>

</body>

</html>
login.jsp
login.jsp ஃபைல் ஆனது கீழே உள்ள படத்தில் உள்ளது போல் இருக்கும்.இந்த பக்கத்தில் நாம் கொடுக்கும் இன்புட் ஆனது டேட்டா பேஸுடன் வேலிடேட் செய்யும் கோடிங்க் உள்ளது.

 
<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<title>Login</title>

</head>

<body>

<%! String userdbName;

String userdbPsw;

String dbUsertype;

%>

<%

Connection con= null;

PreparedStatement ps = null;

ResultSet rs = null;



String driverName = "com.mysql.jdbc.Driver";

String url = "jdbc:mysql://localhost:3306/record";

String user = "root";

String dbpsw = "root";



String sql = "select * from userdetail where name=? and password=? and usertype=?";



String name = request.getParameter("name");

String password = request.getParameter("password");

String usertype = request.getParameter("usertype");



if((!(name.equals(null) || name.equals("")) && !(password.equals(null) ||
password.equals(""))) && !usertype.equals("select"))

{

try{

Class.forName(driverName);

con = DriverManager.getConnection(url, user, dbpsw);

ps = con.prepareStatement(sql);

ps.setString(1, name);

ps.setString(2, password);

ps.setString(3, usertype);

rs = ps.executeQuery();

if(rs.next())

{

userdbName = rs.getString("name");

userdbPsw = rs.getString("password");

dbUsertype = rs.getString("usertype");

if(name.equals(userdbName) && password.equals(userdbPsw) && usertype.equals(dbUsertype))

{

session.setAttribute("name",userdbName);

session.setAttribute("usertype", dbUsertype);

response.sendRedirect("welcome.jsp");

}

}

else

response.sendRedirect("error.jsp");

rs.close();

ps.close();

}

catch(SQLException sqe)

{

out.println(sqe);

}

}

else

{

%>

<center><p style="color:red">Error In Login</p></center>

<%

getServletContext().getRequestDispatcher("/home.jsp").include(request,
response);

}

%>

</body>

</html>
கீழே உள்ளது லாக் இன் ஃபார்ம் ஆகும்.

welcome.jsp
சரியான யூசர் நேம் மற்றும் பாஸ் வேர்டு கொடுக்கும் போது welcome. jsp தோன்றும். அதற்கான கோடிங்க் கீழே உள்ளது.


<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<title>Welcome</title>

</head>

<body>

<p>Welcome, <%=session.getAttribute("name")%></p>

<p><a href="logout.jsp">Logout</a>

</body>

</html>
கீழே உள்ளது லாக் இன் ஃபார்ம் படம்.
error.jsp

error page ஆனது பின் வரும் கோடிங்கை கொண்டிருக்கும்.லாக் இன் டேட்டா தவறு எனில் இது பிழை சுட்டிக் காட்டும்
<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<title>Login Error</title>

</head>

<body>

<center><p style="color:red">Sorry, your record is not available.</p></center>

<%

getServletContext().getRequestDispatcher("/home.jsp").include(request,
response);

%>

</body>

</html>
logout.jsp
 logout page  ஆனது இந்த கோடிங்கை கொண்டிருக்கும்.
 
<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<title>Logout</title>

</head>

<body>

<% session.invalidate(); %>

<p>You have been successfully logout</p>

</body>

</html>
-நன்றி
முத்து கார்த்திகேயன், மதுரை.
ads Udanz