<%

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

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

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

Timestamp register = new Timestamp(System.currentTimeMillis());


Connection conn=null;

PreparedStatement pstmt=null;


String str="";

try{

 String jdbcURL = "jdbc:mysql://localhost:3306/test";

 String dbId="root";

 String dbPass="pass";

 

 Class.forName("com.mysql.jdbc.Driver");

 conn=DriverManager.getConnection(jdbcURL,dbId,dbPass);

 

 String sql="INSERT INTO member VALUES(?,?,?,?)";

 pstmt=conn.prepareStatement(sql);

 pstmt.setString(1,id);

 pstmt.setString(2,passwd);

 pstmt.setString(3,name);

 pstmt.setTimestamp(4,register);

 pstmt.executeUpdate();

 str = "member테이블에 새로운 레코드를 추가하였습니다!";

} catch(Exception e){

 e.printStackTrace();

 str="실패했음";

} finally {

 if(pstmt != null) try{pstmt.close();}catch(SQLException sqle){}

 if(conn !=null) try{conn.close();} catch(SQLException sqle){}

}

%>



'업무 > JSP' 카테고리의 다른 글

[jsp] include 액션태그에서 파라미터 전달하기  (0) 2011.11.09
[jsp] 한글 깨지지 않게 하기  (0) 2011.11.09

+ Recent posts