Reputation: 5157
I am in the process of creating code generator for my CRUD java web database application. In the making of its Form page, I want to be able to present ENUM field data type, into a combo box. So, having this defined in a MySQL script :
`Employment Status` enum('CPNS','PNS') COLLATE latin1_general_ci NOT NULL,
I want to make an Employment Status
as Combo Box (using <SELEC/>
html input type) with CPNS
,PNS
as its content.
How can I enumerate the content of that field from database using JDBC??? Many thanks!
PS : Some my ask, why do I want to create my own code generator??? Well, I think it will be very fun to create such, and add it to our wide choice of alternative in Java Web universe.. :)
Upvotes: 0
Views: 1889
Reputation: 5157
I just got this link : Re: JDBC and ENUM field types, I already test using show columns from table_x where field='employment status'
. It show the enum content. But I still must parse it...
Upvotes: 0
Reputation: 788
DatabaseMetaData meta = conn.getMetaData(); rsColumns = meta.getColumns(null, "%", "", "%"); /*getColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern)*/ while (rsColumns.next()) { String columnType = rsColumns.getString("TYPE_NAME"); String columnName = rsColumns.getString("COLUMN_NAME"); }
I think this can help you.
Upvotes: 1