try
{
Class.forName(
"oracle.jdbc.driver.OracleDriver"
);
}
catch
(ClassNotFoundException e1) {
e1.printStackTrace(pw);
}
Connection conn =
null
;
CallableStatement cstat =
null
;
ResultSet rs =
null
;
try
{
conn = DriverManager.getConnection(
"jdbc:oracle:thin:@아이피:포트:Tnsname"
,
"아이디"
,
"비밀번호"
);
CallableStatement cstat = conn.prepareCall(
"{CALL 패키지명.프로시져명(?)}"
);
cstat.registerOutParameter(
1
, OracleTypes.CURSOR);
cstat.execute();
rs = (ResultSet)cstat.getObject(
1
);
if
( rs !=
null
)
{
ResultSetMetaData rsmeta = rs.getMetaData();
int
nColumn = rsmeta.getColumnCount();
out.println(
""
);
out.println(
""
);
for
(
int
i =
0
; i <= nColumn; i++)
{
if
( i ==
0
)
out.println(
" 번호 "
);
else
{
String strColumnName = rsmeta.getColumnName(i);
out.println(strColumnName);
}
}
out.println(
""
);
int
nRow =
1
;
while
(rs.next())
{
out.println(
""
);
StringBuffer sb =
new
StringBuffer();
for
(
int
i =
0
; i <= nColumn; i++)
{
if
( i ==
0
)
sb.append( Integer.toString(nRow) );
else
sb.append( rs.getString(i) );
}
out.println(sb.toString());
out.println(
""
);
nRow++;
}
out.println(
""
);
}
}
catch
(SQLException e) {
e.printStackTrace(pw);
}
finally
{
try
{rs.close(); }
catch
(SQLException e) {}
try
{cstat.close();}
catch
(SQLException e) {}
try
{conn.close(); }
catch
(SQLException e) {}