Open wangyuehong opened 11 months ago
This is a problem of the JDBC driver: Though Connection.getMetaData().getTableTypes() returns the table type "TYPE" it doesn't return enums from Connection.getMetaData().getTables(...). The test program below illustrates the problem. Please consult your JDBC driver or database vendor about the issue.
public class PgTypeTest
{
public static void main(String[] args) throws ClassNotFoundException, SQLException
{
Class.forName("org.postgresql.Driver");
Connection con = DriverManager.getConnection("<yourDbUrl>", "yourUser", "yourPassword");
ResultSet tableTypes = con.getMetaData().getTableTypes();
System.out.println("Available table types:");
while (tableTypes.next())
{
System.out.println(tableTypes.getString("TABLE_TYPE"));
}
//ResultSet types = con.getMetaData().getTables(null, null, null, null);
ResultSet types = con.getMetaData().getTables(null, null, null, new String[]{"TYPE"});
System.out.println("Available types:");
while (types.next())
{
// Will not get here because types is empty
System.out.println(types.getString("TABLE_NAME"));
}
}
}
sql to create enum in pg database.
aenum
should be shown in object tree underTYPE
.