KickJava   Java API By Example, From Geeks To Geeks.

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


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.constraint.Constraint;
10 import org.h2.engine.Right;
11 import org.h2.engine.Session;
12 import org.h2.schema.Schema;
13
14 /**
15  * @author Thomas
16  */

17 public class AlterTableDropConstraint extends SchemaCommand {
18
19     private String JavaDoc constraintName;
20
21     public AlterTableDropConstraint(Session session, Schema schema) {
22         super(session, schema);
23     }
24
25     public void setConstraintName(String JavaDoc string) {
26         constraintName = string;
27     }
28
29     public int update() throws SQLException JavaDoc {
30         session.commit();
31         Constraint constraint = getSchema().getConstraint(constraintName);
32         session.getUser().checkRight(constraint.getTable(), Right.ALL);
33         session.getUser().checkRight(constraint.getRefTable(), Right.ALL);
34         session.getDatabase().removeSchemaObject(session, constraint);
35         return 0;
36     }
37
38 }
39
Popular Tags