首页新闻找找看学习计划

各位大神!!帮忙看看呗!谢谢myeclipse连接mysql 出现500:错误The server encountered an unexpected condition that prevented it from fulfilling the request.

0
悬赏园豆:5 [已关闭问题] 关闭于 2017-10-18 22:38

<%@ page language="java" import="java.sql.*" pageEncoding="UTF-8"%>
<html>
</head><title>利用PreparedStatement对象添加一条记录页面</title></head>

<body>
<%String driverName="com.mysql.jdbc.Driver";
String userName="root";
String userPwd="184896";
String dbName="students";
String url1="jdbc:mysql://localhost:3306/"+dbName;
String url2="?user="+userName+"&password="+userPwd;
String url3="&userUnicode=true&characterEncoding=UTF-8";
String url=url1+url2+url3;
Class.forName(driverName);
Connection conn=DriverManager.getConnection(url);

String sql="Insert into stu_info(id,name,sex,age,weight,height)values(?,?,?,?,?,?)";
PreparedStatement pstmt=conn.prepareStatement(sql);
pstmt.setInt(1,16);
pstmt.setString(2,"张三");
pstmt.setString(3,"男");
pstmt.setInt(4,20);
pstmt.setFloat(5,70);
pstmt.setFloat(6,175);
int n=pstmt.executeUpdate();
if(n==1){%>数据插入操作成功!<br><%}
else{%>数据插入操作失败!<br><%}
if(pstmt!=null){pstmt.close();}
if(conn!=null){conn.close();}%>
</body>
</html>

小星_log的主页 小星_log | 菜鸟二级 | 园豆:210
提问于:2017-10-18 21:34
< >
分享
所有回答(2)
-1

不知道。。。

野心家 | 园豆:188 (初学一级) | 2017-10-18 21:40
0

把height改为hight

小星_log | 园豆:210 (菜鸟二级) | 2017-10-18 22:38
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册