Database Reference
In-Depth Information
System
.
out
.
println
(
"getTableName: "
+
md
.
getTableName
(
i
));
System
.
out
.
println
(
"isAutoIncrement: "
+
md
.
isAutoIncrement
(
i
));
System
.
out
.
println
(
"isNullable: "
+
md
.
isNullable
(
i
));
System
.
out
.
println
(
"isCaseSensitive: "
+
md
.
isCaseSensitive
(
i
));
System
.
out
.
println
(
"isSigned: "
+
md
.
isSigned
(
i
));
}
rs
.
close
();
s
.
close
();
The program produces this output:
Statement: SELECT name, birth FROM profile
Number of columns: 2
--- Column 1 (name) ---
getColumnDisplaySize: 20
getColumnLabel: name
getColumnType: 12
getColumnTypeName: VARCHAR
getPrecision: 20
getScale: 0
getTableName: profile
isAutoIncrement: false
isNullable: 0
isCaseSensitive: false
isSigned: false
--- Column 2 (birth) ---
getColumnDisplaySize: 10
getColumnLabel: birth
getColumnType: 91
getColumnTypeName: DATE
getPrecision: 10
getScale: 0
getTableName: profile
isAutoIncrement: false
isNullable: 1
isCaseSensitive: false
isSigned: false
The row count of the result set is not available directly; you must fetch the rows and
count them.
JDBC has several other result set metadata calls, but many of them provide no useful
information for MySQL. To try them, get a JDBC reference to see what the calls are and
modify the program to see what, if anything, they return.