求::mysql数据库与 jsp 连接的代码

 我来答
ylongshao1987
2011-03-26 · TA获得超过9811个赞
知道小有建树答主
回答量:1277
采纳率:100%
帮助的人:740万
展开全部
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.sql.*"%>
<%
String sql = "select * from test";

// 连接字符串,格式: "jdbc:数据库驱动名称://数据库服务器ip/数据库名称?user=用户名&password=密码&使用Unicode=布尔值&字符编码=编码"
String url = "jdbc:mysql://localhost/softforum?user=soft&password=soft1234&useUnicode=true&characterEncoding=8859_1";
String username = "scott";
String password = "tiger";

Class.forName("org.gjt.mm.mysql.Driver").newInstance();

Connection conn = DriverManager.getConnection(url, username, password);
Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
ResultSet rs = stmt.executeQuery(sql);

rs.close();
stmt.close();
conn.close();
%>
yujingtaojing
2011-03-25 · TA获得超过467个赞
知道小有建树答主
回答量:1108
采纳率:0%
帮助的人:510万
展开全部
到处都是,就是不愿意自己找。我也懒得找
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

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

类别

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

说明

0/200

提交
取消

辅 助

模 式