Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Java SE 综合讨论区  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 Re:请教个连接数据库的连接问题(有代码) 谢过先 [Re:iceriver2000]
wuzhong





发贴: 9
积分: 0
于 2007-01-17 23:03 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
public class EmpJdbc {
String dbDriver="sun.jdbc.odbc.JdbcOdbcDriver";
String url="jdbc:odbc:mydb";
Connection con=null;
ResultSet rs=null;
public EmpJdbc(){
try{
Class.forName(dbDriver);

}catch(ClassNotFoundException e){
e.printStackTrace();
}
}
public ResultSet executeQuery(String s){
rs=null;
try{
con=DriverManager.getConnection(url);
Statement stm=con.createStatement();
rs=stm.executeQuery(" ");//在这里添加你要查找的表字段名称

}catch(SQLException e){
e.printStackTrace();
}
return rs;
}
public static void main(String args[])throws Exception{
EmpJdbc emjdbc=new EmpJdbc();
String sql="SELLECT*FROM project";
ResultSet rs=emjdbc.executeQuery(sql);
while(rs.next()){
String name=rs.getString("name");
System.out.println(name);

}
}

}




话题树型展开
人气 标题 作者 字数 发贴时间
8442 请教个连接数据库的连接问题(有代码) 谢过先 iceriver2000 977 2007-01-08 12:08
6845 Re:请教个连接数据库的连接问题(有代码) 谢过先 xuelange 39 2007-01-09 09:12
6930 Re:请教个连接数据库的连接问题(有代码) 谢过先 qw2008 10 2007-01-11 17:56
6835 Re:请教个连接数据库的连接问题(有代码) 谢过先 gwangmm 10 2007-01-12 15:25
6785 Re:请教个连接数据库的连接问题(有代码) 谢过先 why 21 2007-01-12 20:11
6731 Re:请教个连接数据库的连接问题(有代码) 谢过先 jg0021 113 2007-01-16 20:43
7070 Re:请教个连接数据库的连接问题(有代码) 谢过先 wuzhong 903 2007-01-17 23:03
6849 Re:请教个连接数据库的连接问题(有代码) 谢过先 why 86 2007-01-20 19:24

flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923