jdbcTest

来源:互联网 发布:程序员客栈一个月收入 编辑:程序博客网 时间:2024/06/08 14:24

jdbc链接数据库伪代码:

public class TestJdbc

{

Connection conn=null;

Prestament ps=null;

ResultSet rs=null;

Class.Forname=(com.mysql.jdbc.driven)

conn=Drivemanger.getconnection(url,username,password)
Srring sql="Select * from employller"
ps=conn.paredstament(sql);
rs=ps.exeuquery(sql);
while(rs.next)
{
Syso("id:"+rs.getInt(1)+"name:"+rs.getString(2))


}
if(rs!=null)
{
rs.close
}
if(ps!=null)
{
ps.close
}

}

0 0
原创粉丝点击