java 如何接收 oracle 的 select 查询结果 并赋值给变量

[复制链接]
查看11 | 回复3 | 2013-4-16 10:24:01 | 显示全部楼层 |阅读模式
public Int find(){Connection conn = null;int a = 0;try{
try {
//1 注册驱动程序
Class.forName("oracle.jdbc.driver.OracleDriver");
//2 连接数据库
conn = DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:ORCL","scott","tiger");
}catch(Exception e) {
System.out.println("没有得到数...
回复

使用道具 举报

千问 | 2013-4-16 10:24:01 | 显示全部楼层
你的deptno=40的部门下有几个员工呢?如果只是一个,那么直接赋值给a就行,如果有多个,你就不能只用一个变量a来接受了,得用数组或集合等。...
回复

使用道具 举报

千问 | 2013-4-16 10:24:01 | 显示全部楼层
Listvlist =s.executeQuery("select host_client from emp where deptno=40").list();Iteratro it =vlist.iterator();while(it.hasNext()){Empemp=(Emp )it.next();// 转换为ENTITY ...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行