Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2476064
  • 博文数量: 153
  • 博客积分: 8010
  • 博客等级: 中将
  • 技术积分: 1680
  • 用 户 组: 普通用户
  • 注册时间: 2006-04-02 10:43
个人简介

IT精英-请移步http://www.ithtu.com

文章分类

全部博文(153)

文章存档

2011年(3)

2010年(5)

2009年(17)

2008年(20)

2007年(76)

2006年(32)

我的朋友

分类: Java

2007-07-01 16:30:07

简单的连接语句:
try{ Class.forName("org.gjt.mm.mysql.Driver"); Connection conn=DriverManager.getConnection("jdbc:mysql://localhost/test","root","zqy01"); /* 注:test为数据库名称,root为用户名,zqy01为密码 */ Statement stmt=conn.createStatement(); String sql="select * from users where username='"+username+"'"; sql+="and password='"+password+"'"; ResultSet rs=stmt.executeQuery(sql); if(rs.next()){ ........./*这部分省略了*/ }
阅读(953) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~