KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > h2 > command > ddl > DropUserDataType


1 /*
2  * Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
3  * Initial Developer: H2 Group
4  */

5 package org.h2.command.ddl;
6
7 import java.sql.SQLException JavaDoc;
8
9 import org.h2.engine.Database;
10 import org.h2.engine.Session;
11 import org.h2.engine.UserDataType;
12 import org.h2.message.Message;
13
14 public class DropUserDataType extends DefineCommand {
15
16     private String JavaDoc typeName;
17     private boolean ifExists;
18     
19     public DropUserDataType(Session session) {
20         super(session);
21     }
22     
23     public void setIfExists(boolean ifExists) {
24         this.ifExists = ifExists;
25     }
26
27     public int update() throws SQLException JavaDoc {
28         session.getUser().checkAdmin();
29         session.commit();
30         Database db = session.getDatabase();
31         UserDataType type = db.findUserDataType(typeName);
32         if(type == null) {
33             if(!ifExists) {
34                 throw Message.getSQLException(Message.USER_DATA_TYPE_NOT_FOUND_1, typeName);
35             }
36         } else {
37             db.removeDatabaseObject(session, type);
38         }
39         return 0;
40     }
41
42     public void setTypeName(String JavaDoc name) {
43         this.typeName = name;
44     }
45
46 }
47
48
Popular Tags