1
2
3
4 package myx;
5
6 import java.sql.PreparedStatement;
7 import java.sql.SQLException;
8 import java.util.logging.Level;
9 import java.util.logging.Logger;
10
11 import org.xmldb.api.base.Collection;
12 import org.xmldb.api.base.ErrorCodes;
13 import org.xmldb.api.base.XMLDBException;
14 import org.xmldb.api.modules.CollectionManagementService;
15
16 import java.sql.Connection;
17
18 /***
19 * @author Mladen Adamovic (adamm@blic.net)
20 */
21 public class myxCollectionManagementService implements
22 CollectionManagementService {
23
24 private static Logger logger = Logger.getLogger(myxCollectionManagementService.class.getName());
25
26 myxDatabase db;
27
28 public myxCollectionManagementService() {
29 super();
30 db = new myxDatabase();
31 }
32
33
34
35
36
37
38
39
40 /***
41 * @see org.xmldb.api.modules.CollectionManagementService#createCollection(java.lang.String)
42 */
43 public Collection createCollection(String name) throws XMLDBException {
44 PreparedStatement stmt;
45 try {
46 stmt = db.getConnection().prepareStatement("create table " + name
47 + "( name char(128) not null," + "content longtext,"
48 + "primary key(name) )");
49 stmt.execute();
50 } catch (SQLException e) {
51 throw new XMLDBException(ErrorCodes.VENDOR_ERROR,
52 "Problem creating the collection "+name+" ("+e.getMessage()+")");
53 }
54 return new myxCollection(db, name);
55 }
56
57 /***
58 * @see org.xmldb.api.modules.CollectionManagementService#removeCollection(java.lang.String)
59 */
60 public void removeCollection(String name) throws XMLDBException {
61 PreparedStatement stmt;
62 try {
63 db.openConnection();
64 stmt = db.getConnection().prepareStatement("drop table "+name);
65 stmt.execute();
66 db.closeConnection();
67 } catch (SQLException e) {
68 throw new XMLDBException(ErrorCodes.VENDOR_ERROR,
69 "Problem removing the collection "+name+" ("+e.getMessage()+")");
70 }
71
72 }
73
74 /***
75 * @see org.xmldb.api.base.Service#getName()
76 */
77 public String getName() throws XMLDBException {
78
79 return null;
80 }
81
82 /***
83 * @see org.xmldb.api.base.Service#getVersion()
84 */
85 public String getVersion() throws XMLDBException {
86
87 return null;
88 }
89
90 /***
91 * @see org.xmldb.api.base.Service#setCollection(org.xmldb.api.base.Collection)
92 */
93 public void setCollection(Collection col) throws XMLDBException {
94
95
96 }
97
98 /***
99 * @see org.xmldb.api.base.Configurable#getProperty(java.lang.String)
100 */
101 public String getProperty(String name) throws XMLDBException {
102
103 return null;
104 }
105
106 /***
107 * @see org.xmldb.api.base.Configurable#setProperty(java.lang.String,
108 * java.lang.String)
109 */
110 public void setProperty(String name, String value) throws XMLDBException {
111
112
113 }
114
115 }