package member.dto;
public class MemberDTO {
private String id;
private String password;
private String name;
private String registerNumber;
private int mileage;
public MemberDTO() {
super();
}
public MemberDTO(String id, String password, String name,
String registerNumber, int mileage) {
super();
this.id = id;
this.password = password;
this.name = name;
this.registerNumber = registerNumber;
this.mileage = mileage;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getRegisterNumber() {
return registerNumber;
}
public void setRegisterNumber(String registerNumber) {
this.registerNumber = registerNumber;
}
public int getMileage() {
return mileage;
}
public void setMileage(int mileage) {
this.mileage = mileage;
}
@Override
public String toString() {
return "MemberDTO [id=" + id + ", password=" + password + ", name="
+ name + ", registerNumber=" + registerNumber + ", mileage="
+ mileage + "]";
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result + mileage;
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result
+ ((password == null) ? 0 : password.hashCode());
result = prime * result
+ ((registerNumber == null) ? 0 : registerNumber.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
MemberDTO other = (MemberDTO) obj;
if (id == null) {
if (other.id != null)
return false;
} else if (!id.equals(other.id))
return false;
if (mileage != other.mileage)
return false;
if (name == null) {
if (other.name != null)
return false;
} else if (!name.equals(other.name))
return false;
if (password == null) {
if (other.password != null)
return false;
} else if (!password.equals(other.password))
return false;
if (registerNumber == null) {
if (other.registerNumber != null)
return false;
} else if (!registerNumber.equals(other.registerNumber))
return false;
return true;
}
}
package member.listener;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
public class DriverLoadingListener implements ServletContextListener {
public DriverLoadingListener() {
}
public void contextInitialized(ServletContextEvent arg0) {
//web.xml에 있는 Context읽어오기(초기 파라미터)
ServletContext ctx = arg0.getServletContext();
//web.xml에 있는 driver class 읽어오기
String driverClass = ctx.getInitParameter("driver class");
try {
//어플리케이션이 시작할 때 driver class 로딩
Class.forName(driverClass);
System.out.println("-----Driver Loading 성공------");
} catch (Exception e) {
}
}
public void contextDestroyed(ServletContextEvent arg0) {
}
}
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>member_servlet</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<context-param>
<param-name>driver class</param-name>
<param-value>oracle.jdbc.driver.OracleDriver</param-value>
</context-param>
<context-param>
<param-name>url</param-name>
<param-value>jdbc:oracleLthinL@127.0.0.1:1521:XE</param-value>
</context-param>
<context-param>
<param-name>user</param-name>
<param-value>scott</param-value>
</context-param>
<context-param>
<param-name>password</param-name>
<param-value>tiger</param-value>
</context-param>
<listener>
<listener-class>member.listener.DriverLoadingListener</listener-class>
</listener>
</web-app>