public static void main(String[] args) {
try {
Connection c = null;
Class.forName("org.postgresql.Driver");
c = DriverManager.getConnection(
"jdbc:postgresql://localhost:5432/postgres", // db
"postgres", // account
"ForOnlyOneTick1" // password
);
Object loc = Dimension.class;
PreparedStatement insertNew = c
.prepareStatement("CREATE TYPE loc AS (?);");
insertNew.setObject(1, loc);
insertNew.executeUpdate();
insertNew.close();
c.close();
} catch (Exception e) {
//e.printStackTrace();
System.err.println(e.getClass().getName() + ": " + e.getMessage());
}
}
이 예제에서는 데이터베이스에 차원 유형을 만들려고했습니다. 하지만 작동하지 않습니다.POSTGRES SQL JAVA는 Java 클래스로 사용자 정의 유형을 만듭니다.
particolar 유형의 Java 클래스로 열을 만들 수 있습니까?
또는 데이터베이스에서 알고있는 유형 만 사용할 수 있습니까?
예를 들어: 내가 같은 유형 작성해야하는 경우
CREATE TYPE location AS (x int, y int, z int, name VARCHAR(15));
OK,하지만 문제가 계속 : 공공의 값을 서로
CREATE TYPE land AS (area Dimension, people ListPeople, probability int, cause Causes);
차원, 원인은 내 사용자 정의 클래스는 ListPeople 있습니다 수업.