<%@page import="java.sql.Connection" %>
<%@page import="java.sql.DriverManager" %>
<%@page import="java.sql.SQLException" %>
<%@page import="java.sql.*" %>
<%
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/YesOrNo", "root","c8827349");
Statement stmt = conn.createStatement();
try{
String sql = "SELECT QUESTION_ID,WRITER_ID FROM TB_VOTE WHERE QUESTION_ID='1' and WRITER_ID='jijs' ";
conn.setAutoCommit(false);
ResultSet rs = stmt.executeQuery(sql);
Boolean flag=rs.next();
rs.close();
System.out.println("flag="+flag);
out.println("flag="+flag);
Thread.sleep(10000);
if(flag==false){
stmt.execute("INSERT INTO TB_VOTE (QUESTION_ID,WRITER_ID,VOTE_FLAG) VALUES (1,'jijs',1)");
}
conn.commit();
}catch(SQLException e1){
System.out.println("e1="+e1);
if(conn!=null)
try{
conn.rollback();
}catch(SQLException e2){
System.out.println("e2="+e2);
}
}
%>
<html>
<body>
<h2>Hello World!</h2>
</body>
</html>
'PROGRAMING > JSP' 카테고리의 다른 글
트랜잭션 격리레벨 테슽.... (0) | 2015.08.06 |
---|