blogjava's web log
blogjava's web log
...
java調oracle返回游標
create
?
or
?
replace
?package?mypack?
is
?Type?ref_cur?
is
?ref?
cursor
;
?
function
?getCur?
return
?ref_cur;
end
;?
create
?
or
?
replace
?package?body?mypack?
as
??
function
?getCur?
return
?ref_cur?
is
????cur1?ref_cur?;
????
begin
???????
open
?cur1?
for
?
select
?
*
?
from
?sales;
???????
return
?cur1;
????
end
;?
??
end
?mypack;
??
?
?
--
java代碼
??
package
?store;
import
?java.sql.
*
;
import
?oracle.jdbc.
*
;
public
?
class
?Test?
{
????
public
?Test()?
{
????}
???Connection?conn?
=
?
null
;
????
public
?
static
?
void
?main(String[]?args)?
{
????????Test?test?
=
?
new
?Test();
????????test.openCursor();
????}
????
private
?
void
?getConnection()?
throws
?ClassNotFoundException,?SQLException?
{
????????Class.forName(
"
oracle.jdbc.driver.OracleDriver
"
);
????????String?url
=
"
jdbc:oracle:thin:@localhost:1521:ydgl
"
;
????????conn
=
DriverManager.getConnection(url,
"
system
"
,
"
manager
"
);
????}
????
public
?
void
?openCursor()
????
{
???
???ResultSet?rs?
=
?
null
;
???CallableStatement?stmt?
=
?
null
;
???String?sql?
=
?
"
{??=?call?mypack.getCur()}
"
;
??
try
??
{?
???getConnection();
???stmt?
=
?conn.prepareCall(sql);
???stmt.registerOutParameter(
1
,OracleTypes.CURSOR);
???stmt.execute();
???rs?
=
?((OracleCallableStatement)stmt).getCursor(
1
);
???
while
(rs.next())
??
{
???String?xm?
=
?rs.getString(
1
);
???Date?dtime?
=
?rs.getDate(
2
);
???
int
?count
=
rs.getInt(
3
);
???String?city
=
rs.getString(
5
);
???System.out.println(
"
name:
"
+
xm
+
"
?|?Time:
"
+
?dtime.toLocaleString()
+
"
?|?Count:
"
+
count
+
"
?|City:
"
+
city);
???}
?}
catch
(Exception?ex)
{
???ex.printStackTrace();
??}
}
?
posted on 2006-04-28 21:11
record java and net
閱讀(980)
評論(0)
編輯
收藏
所屬分類:
java
新用戶注冊
刷新評論列表
只有注冊用戶
登錄
后才能發表評論。
網站導航:
博客園
IT新聞
Chat2DB
C++博客
博問
管理
相關文章:
[推薦]系統發郵件測試 Dumbster
Selenium測試 使用筆記
JDBC 4.0 Enhancements in Java SE 6
java連接postgreSQL數據庫簡單使用
我的收藏夾-2006-06-26
這些題目,你能答對多少?
java調oracle返回游標
XML在Java中的應用
導航
首頁
聯系
聚合
管理
常用鏈接
我的隨筆
我的評論
我的參與
最新評論
留言簿
(44)
給我留言
查看公開留言
查看私人留言
新聞檔案
2007年5月 (1)
2007年4月 (1)
2007年3月 (4)
2007年1月 (8)
2006年12月 (16)
2006年11月 (3)
2.動態語言
IronPython
JRuby
Python
Rails Framework Documentation
Ruby Central
Ruby on rails
Ruby On Rails中文社區
Ruby 中文社區
Ruby_cn (blog)
ruby-doc
Rubyforge
Ruby-lang
3.工具箱
computer performance
寫字找圖片
網站歷史查詢
驅動
9.
文檔教程
Free Computer Books
New!
Spring2.0中文參考手冊
New
Apache ant1.6.2源代碼
Apache2.2 文檔
Dhtml參考
hibernate三中文文檔
java api
javascript參考
mysql中文文檔
NHibernate 1.2文檔
Spring - Framework
spring--教程
spring源代碼學習
XPath 教程
夏昕ibatis
夏昕的Hibernate
夏昕的Spring
友情鏈接
搬家公司
討債公司
搜索
最新評論
1.?re: 周公解夢夢見豬血灑頭上手上
不錯
--娟娟
Powered by:
BlogJava
Copyright © record java and net
主站蜘蛛池模板:
湾仔区
|
临沭县
|
开鲁县
|
读书
|
富川
|
瓦房店市
|
谷城县
|
城固县
|
古田县
|
瑞金市
|
齐齐哈尔市
|
五常市
|
达尔
|
开远市
|
耒阳市
|
蛟河市
|
墨脱县
|
泸西县
|
唐海县
|
盐津县
|
磴口县
|
田阳县
|
永清县
|
清丰县
|
开江县
|
翼城县
|
桐城市
|
潮州市
|
镇安县
|
营口市
|
阿拉善左旗
|
越西县
|
泸定县
|
怀集县
|
桂东县
|
涟水县
|
山东省
|
青浦区
|
延寿县
|
安多县
|
五华县
|