日期:2014-05-17 浏览次数:20636 次
<body>
<img src="thumbs/9.jpg" width="179" height="100" alt="" onclick="show_id2('9')"/>
<script type="text/javascript" src="1.js"></script>
</body>
var tu1;
tu1 = 3;
function show_id2(str){
tu1 = str;
}
<body>
Connection conn=null;
PreparedStatement pstmt = null;
try {
Class.forName("com.mysql.jdbc.Driver");//加载JDBC驱动程序
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/bbs","root","root");//连接MySQL数据库
}catch (ClassNotFoundException e) {
out.println("找不到驱动类");
} catch (SQLException e) {
out.println("连接MySQL数据库失败");
}
try{
Statement stmt = conn.createStatement();
String queryAll = "insert into user(id,username,password,email,sex) values(null,'candy','123','666','nan');";
int rs = stmt.executeUpdate(queryAll);
//获得所有记录
if(rs != 0)
{
out.println(tu1);
}
else
{
response.sendRedirect("No.jsp");
}
}catch (SQLException e) {
out.println("查询用户信息失败");
e.printStackTrace();
}
%>
</body>