This guide provides a detailed walkthrough for configuring Wikantik to use a relational database for storing user and group information, with a specific focus on MySQL.
Wikantik can be configured to use a relational database for user and group management instead of the default XML files. This is highly recommended for production environments as it offers better performance, scalability, and security.
Wikantik uses JNDI (Java Naming and Directory Interface) to look up the database connection, which means you'll need to configure a JNDI DataSource in your application server (e.g., Tomcat).
Download the appropriate JDBC driver for your database and place it in the lib directory of your Tomcat installation ($CATALINA_HOME/lib).


To configure the JNDI DataSource, you'll need to add a <Resource> element to your Tomcat's conf/context.xml file.
<Context>
...
<Resource name="jdbc/WikiDatabase" auth="Container"
type="javax.sql.DataSource" maxTotal="30" maxIdle="30"
maxWaitMillis="10000" username="your_username" password="your_password"
driverClassName="com.mysql.cj.jdbc.Driver"
url="jdbc:mysql://localhost:3306/jspwiki?useSSL=false"/>
...
</Context>
<Context>
...
<Resource name="jdbc/WikiDatabase" auth="Container"
type="javax.sql.DataSource" maxTotal="30" maxIdle="30"
maxWaitMillis="10000" username="your_username" password="your_password"
driverClassName="org.postgresql.Driver"
url="jdbc:postgresql://localhost:5432/jspwiki"/>
...
</Context>
Note:
your_username and your_password with your database credentials.url parameter should point to your database server and database name.Update your wikantik-custom.properties file to use the JDBCUserDatabase and JDBCGroupDatabase.
# Use the JDBC user and group databases
jspwiki.userdatabase = com.wikantik.auth.user.JDBCUserDatabase
jspwiki.groupdatabase = com.wikantik.auth.authorize.JDBCGroupDatabase
# Shared JNDI DataSource name
wikantik.datasource = jdbc/WikiDatabase
Wikantik does not automatically create the necessary tables in the database. You'll need to create them manually.
CREATE TABLE users (
uid VARCHAR(255) NOT NULL,
login_name VARCHAR(255) NOT NULL,
full_name VARCHAR(255),
password VARCHAR(255),
email VARCHAR(255),
created DATETIME,
attributes TEXT,
PRIMARY KEY (uid)
);
CREATE TABLE groups (
id INT NOT NULL AUTO_INCREMENT,
name VARCHAR(255) NOT NULL,
creator VARCHAR(255),
created DATETIME,
modifier VARCHAR(255),
modified DATETIME,
PRIMARY KEY (id)
);
CREATE TABLE group_members (
group_id INT NOT NULL,
user_id VARCHAR(255) NOT NULL,
FOREIGN KEY (group_id) REFERENCES groups(id),
FOREIGN KEY (user_id) REFERENCES users(uid)
);
CREATE TABLE users (
uid VARCHAR(255) NOT NULL,
login_name VARCHAR(255) NOT NULL,
full_name VARCHAR(255),
password VARCHAR(255),
email VARCHAR(255),
created TIMESTAMP,
attributes TEXT,
PRIMARY KEY (uid)
);
CREATE TABLE groups (
id SERIAL PRIMARY KEY,
name VARCHAR(255) NOT NULL,
creator VARCHAR(255),
created TIMESTAMP,
modifier VARCHAR(255),
modified TIMESTAMP
);
CREATE TABLE group_members (
group_id INT NOT NULL,
user_id VARCHAR(255) NOT NULL,
FOREIGN KEY (group_id) REFERENCES groups(id),
FOREIGN KEY (user_id) REFERENCES users(uid)
);
While the configuration is similar for both databases, there are a few key differences to be aware of:
AUTO_INCREMENT in MySQL vs. SERIAL in PostgreSQL).By following these steps, you can successfully configure Wikantik to use a relational database for user and group management, providing a more robust and scalable solution for your wiki.