jsp 连接mysql数据库查询操作出错
如题。。。错误代码如下org.apache.jasper.JasperException:AnexceptionoccurredprocessingJSPpage/MyJ...
如题。。。错误代码如下
org.apache.jasper.JasperException: An exception occurred processing JSP page /MyJsp.jsp at line 36
33: Statement stm=conn.createStatement();%>
34: <% String sql="select name from st where id='1'";
35: ResultSet rs=stm.executeQuery(sql);
36: String name=rs.getString(1);
37: %>
38: <%out.print(name); %>
39: <%rs.close();
我的数据库中st表是这样的
mysql> desc st;
+--------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+-------+
| id | int(11) | YES | | NULL | |
| name | varchar(20) | YES | | NULL | |
| sex | varchar(5) | YES | | NULL | |
| age | int(11) | YES | | NULL | |
| weight | float | YES | | NULL | |
| height | float | YES | | NULL | |
+--------+-------------+------+-----+---------+-------+
6 rows in set
mysql> select * from st;
+----+------+-----+-----+--------+--------+
| id | name | sex | age | weight | height |
+----+------+-----+-----+--------+--------+
| 1 | 小红 | 女 | 20 | 100 | 160 |
+----+------+-----+-----+--------+--------+
1 row in set
请问各位大神是哪里出错了啊?
删除等操作都能执行,就是查询后的结果集进行赋值时出错。。。 展开
org.apache.jasper.JasperException: An exception occurred processing JSP page /MyJsp.jsp at line 36
33: Statement stm=conn.createStatement();%>
34: <% String sql="select name from st where id='1'";
35: ResultSet rs=stm.executeQuery(sql);
36: String name=rs.getString(1);
37: %>
38: <%out.print(name); %>
39: <%rs.close();
我的数据库中st表是这样的
mysql> desc st;
+--------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+-------+
| id | int(11) | YES | | NULL | |
| name | varchar(20) | YES | | NULL | |
| sex | varchar(5) | YES | | NULL | |
| age | int(11) | YES | | NULL | |
| weight | float | YES | | NULL | |
| height | float | YES | | NULL | |
+--------+-------------+------+-----+---------+-------+
6 rows in set
mysql> select * from st;
+----+------+-----+-----+--------+--------+
| id | name | sex | age | weight | height |
+----+------+-----+-----+--------+--------+
| 1 | 小红 | 女 | 20 | 100 | 160 |
+----+------+-----+-----+--------+--------+
1 row in set
请问各位大神是哪里出错了啊?
删除等操作都能执行,就是查询后的结果集进行赋值时出错。。。 展开
3个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询