java+eclipse+tomcat连接mysql数据库问题 谢谢回答 15

我把jdbc保存到tomcat\lib目录下在classpath中添加了环境变量,jsp代码如下:<%@pagecontentType="text/html;charse... 我把jdbc保存到tomcat\lib目录下 在classpath中添加了环境变量,jsp代码如下:
<%@ page contentType = "text/html; charset = gb2312" %>
<%@ page language = "java" %>
<%@ page import = "com.mysql.jdbc.Driver" %>
<%@ page import = "java.sql.*" %>
<%
String driverName = "com.mysql.jdbc.Driver";
String userName = "root";
String userPasswd = "root";
String dbName = "test";
String tableName = "student";
String url = "jdbc:mysql://192.168.1.62:3306/test?user = userName&password = userPasswd";
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection connection = DriverManager.getConnection(url);
Statement statement = connection.createStatement();
String sql = "select * from student";
ResultSet rs = statement.executeQuery(sql);
ResultSetMetaData rmeta = rs.getMetaData();
int numColumns = rmeta.getColumnCount();
out.print("id");
out.print("|");
out.print("name");
out.print("<br>");
while(rs.next()){
out.print(rs.getString(2) + " ");
out.print("|");
out.print(rs.getString(3) + " ");
out.print("<br>");
}
out.print("<br>");
out.print("数据库操作成功,恭喜你");
rs.close();
statement.close();
connection.close();
%>
tomcat报错如下:
三月 01, 2015 4:25:02 下午 org.apache.tomcat.util.digester.SetPropertiesRule begin
警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:DbConnection' did not find a matching property.
展开
 我来答
SXMiaoChuang
2015-03-01 · 超过18用户采纳过TA的回答
知道答主
回答量:44
采纳率:0%
帮助的人:28.4万
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式