blogjava's web log
blogjava's web log
...
java調(diào)oracle返回游標(biāo)
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
閱讀(982)
評論(0)
編輯
收藏
所屬分類:
java
新用戶注冊
刷新評論列表
只有注冊用戶
登錄
后才能發(fā)表評論。
網(wǎng)站導(dǎo)航:
博客園
IT新聞
Chat2DB
C++博客
博問
管理
相關(guān)文章:
[推薦]系統(tǒng)發(fā)郵件測試 Dumbster
Selenium測試 使用筆記
JDBC 4.0 Enhancements in Java SE 6
java連接postgreSQL數(shù)據(jù)庫簡單使用
我的收藏夾-2006-06-26
這些題目,你能答對多少?
java調(diào)oracle返回游標(biāo)
XML在Java中的應(yīng)用
導(dǎo)航
首頁
聯(lián)系
聚合
管理
常用鏈接
我的隨筆
我的評論
我的參與
最新評論
留言簿
(44)
給我留言
查看公開留言
查看私人留言
新聞檔案
2007年5月 (1)
2007年4月 (1)
2007年3月 (4)
2007年1月 (8)
2006年12月 (16)
2006年11月 (3)
2.動態(tài)語言
IronPython
JRuby
Python
Rails Framework Documentation
Ruby Central
Ruby on rails
Ruby On Rails中文社區(qū)
Ruby 中文社區(qū)
Ruby_cn (blog)
ruby-doc
Rubyforge
Ruby-lang
3.工具箱
computer performance
寫字找圖片
網(wǎng)站歷史查詢
驅(qū)動
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源代碼學(xué)習(xí)
XPath 教程
夏昕ibatis
夏昕的Hibernate
夏昕的Spring
友情鏈接
搬家公司
討債公司
搜索
最新評論
1.?re: 周公解夢夢見豬血灑頭上手上
不錯
--娟娟
Powered by:
BlogJava
Copyright © record java and net
主站蜘蛛池模板:
木里
|
铁力市
|
思南县
|
兴义市
|
滕州市
|
彭水
|
贞丰县
|
科尔
|
图片
|
噶尔县
|
西畴县
|
康定县
|
宜昌市
|
柘城县
|
平邑县
|
林甸县
|
青田县
|
虎林市
|
乐都县
|
安阳市
|
黑龙江省
|
阿勒泰市
|
桂阳县
|
枝江市
|
罗定市
|
望都县
|
南溪县
|
图片
|
桐柏县
|
昌吉市
|
黄骅市
|
临沭县
|
上林县
|
泸水县
|
张家口市
|
祁门县
|
兴化市
|
肥东县
|
友谊县
|
西乌珠穆沁旗
|
开平市
|