Java Reference
In-Depth Information
}
@Override
public
public
int
throws
IOException
,
SQLException
{
ResultSetMetaData md
=
rs
.
getMetaData
();
int
int
write
(
ResultSet rs
)
throws
int
colCount
=
md
.
getColumnCount
();
for
for
(
int
int
i
=
1
;
i
<=
colCount
;
i
++) {
print
(
md
.
getColumnName
(
i
) +
"\t"
);
}
println
();
int
int
rowCount
=
0
;
while
while
(
rs
.
next
()) {
++
rowCount
;
for
for
(
int
int
i
=
1
;
i
<=
colCount
;
i
++) {
print
(
rs
.
getString
(
i
) +
"\t"
);
}
println
();
}
return
return
rowCount
;
}
@Override
public
public
void
void
displayTable
(
String table
,
ResultSet rs
)
throws
throws
IOException
,
SQLException
{
write
(
rs
);
}
@Override
public
public
void
void
printRowCount
(
int
int
rowCount
)
throws
throws
IOException
{
println
(
"Rows: "
+
rowCount
);
}
/* (non-Javadoc)
* @see ResultsDecorator#getName()
*/
@Override
public
public
String
getName
() {
return
return
"Plain text"
;
}
}
Example 18-14. SQLRunner.java