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
主站蜘蛛池模板:
时尚
|
望谟县
|
青龙
|
延津县
|
琼中
|
太仓市
|
北票市
|
宣化县
|
临武县
|
翁牛特旗
|
浙江省
|
衡阳县
|
噶尔县
|
沂南县
|
淮滨县
|
桃园县
|
黄陵县
|
明光市
|
军事
|
昭通市
|
吉林市
|
清水县
|
巴中市
|
锡林郭勒盟
|
武安市
|
固始县
|
水富县
|
宁晋县
|
灵璧县
|
绥宁县
|
鹤峰县
|
雷波县
|
广南县
|
麻栗坡县
|
金塔县
|
阿坝县
|
桃江县
|
濉溪县
|
黑河市
|
平和县
|
句容市
|