Commit ccb1c6dc authored by Daniel Henninger's avatar Daniel Henninger Committed by dhenninger

Created DB access plugin for easy database debugging and such.

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@10807 b35dd754-fafc-0310-a699-88a17e54d16e
parent 99322498
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Packet Filter Plugin Changelog</title>
<style type="text/css">
BODY {
font-size : 100%;
}
BODY, TD, TH {
font-family : tahoma, verdana, arial, helvetica, sans-serif;
font-size : 0.8em;
}
H2 {
font-size : 10pt;
font-weight : bold;
padding-left : 1em;
}
A:hover {
text-decoration : none;
}
H1 {
font-family : tahoma, arial, helvetica, sans-serif;
font-size : 1.4em;
font-weight: bold;
border-bottom : 1px #ccc solid;
padding-bottom : 2px;
}
TT {
font-family : courier new, sans-serif;
font-weight : bold;
color : #060;
}
PRE {
font-family : courier new, sans-serif;
font-size : 100%;
}
</style>
</head>
<body>
<h1>
DB Access Plugin Changelog
</h1>
<p><b>1.0</b> -- Aug 27, 2008</p>
<ul>
<li>Initial release. </li>
</ul>
</body>
</html>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<plugin>
<class>org.jivesoftware.openfire.plugin.DbAccessPlugin</class>
<name>DB Access</name>
<description>Provides administrators with a simple direct access interface to their Openfire DB.</description>
<author>Daniel Henninger</author>
<version>1.0.0</version>
<date>8/27/2008</date>
<minServerVersion>3.0.0</minServerVersion>
<adminconsole>
<tab id="tab-server">
<sidebar id="sidebar-server-manager">
<item id="db-access" name="DB Access"
url="db-access.jsp"
description="Direct database manipulation tool." />
</sidebar>
</tab>
</adminconsole>
</plugin>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>DB Access Plugin Readme</title>
<style type="text/css">
BODY {
font-size : 100%;
}
BODY, TD, TH {
font-family : tahoma, verdana, arial, helvetica, sans-serif;
font-size : 0.8em;
}
H2 {
font-size : 10pt;
font-weight : bold;
}
A:hover {
text-decoration : none;
}
H1 {
font-family : tahoma, arial, helvetica, sans-serif;
font-size : 1.4em;
font-weight: bold;
border-bottom : 1px #ccc solid;
padding-bottom : 2px;
}
TT {
font-family : courier new, sans-serif;
font-weight : bold;
color : #060;
}
PRE {
font-family : courier new, sans-serif;
font-size : 100%;
}
</style>
</head>
<body>
<h1>
DB Access Plugin Readme
</h1>
<h2>Overview</h2>
<p>
This plugin provides nothing more than a very simplistic direct DB access tool in the admin console under
Server -&gt; Server Management. It's purpose is to allow admins to work with their DBs during debugging
sessions to try to determine the state of their DB and maybe make minor adjustments. It should <b>NOT</b>
be used normally and you should <b>never</b> edit your DB while Openfire is running without knowing absolutely
what you are doing. Openfire caches a lot of data in the backend and changing things out from under it will
confuse it and probably cause a wealth of problems. Most likely if you are installing this, it's because
someone asked you to. =)
</p>
<h2>Installation</h2>
<p>Copy dbaccess.jar into the plugins directory of your Openfire installation. The
plugin will then be automatically deployed. To upgrade to a new version, copy the new
dbaccess.jar file over the existing file.</p>
</body>
</html>
\ No newline at end of file
/**
* $Revision$
* $Date$
*
* Copyright (C) 2008 Daniel Henninger. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution.
*/
package org.jivesoftware.openfire.plugin;
import org.jivesoftware.openfire.container.Plugin;
import org.jivesoftware.openfire.container.PluginManager;
import java.io.File;
/**
* This is a stub for now, really does nothing for the plugin what-so-ever.
*
* @author Daniel Henninger
*/
public class DbAccessPlugin implements Plugin {
public void initializePlugin(PluginManager manager, File pluginDirectory) {
// Nothing to do
}
public void destroyPlugin() {
// Nothing to do
}
}
<%@ page import="org.jivesoftware.database.DbConnectionManager" %>
<%@ page import="java.sql.*" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
<%
// Get parameters
boolean execute = request.getParameter("execute") != null;
String sql = request.getParameter("sql");
%>
<html>
<head>
<title>DB Access Tool</title>
<meta name="pageID" content="db-access"/>
</head>
<body>
<div class="information">
Do <b>NOT</b> use this to edit your database unless you know what you are doing. Openfire will not necessarily
handle changes to it's database out from under it while it is running. Most likely you were asked to try a
couple of commands by whoever recommended this plugin, so please try to stick to that (or read-only activities).
</div>
<div>
<h3>SQL Statement:</h3>
<form action="db-access.jsp" method="post">
<textarea rows="10" cols="80" name="sql"><%= sql != null ? sql : "" %></textarea>
<br />
<input type="submit" name="execute" value="Execute SQL"/>
</form>
</div>
<div>
<h3>SQL Output:</h3>
<div style="width: 100%; height: 200px; border: 1.0px solid #000000; overflow: scroll" id="output">
<%
// Handle an execution
if (execute) {
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
try {
con = DbConnectionManager.getConnection();
stmt = con.createStatement();
// SQL
out.println("<p>Your query: <b>" + sql + "</b></p>");
stmt.execute(sql);
rs = stmt.getResultSet();
if (rs == null) {
// print updatecount
out.println("<p>Result: updateCount = <b>" + stmt.getUpdateCount() + "</p>");
} else {
// process resultset
out.println("<br>Your response:");
ResultSetMetaData md = rs.getMetaData();
int count = md.getColumnCount();
out.println("<table border=1>");
out.print("<tr>");
for (int i=1; i<=count; i++) {
out.print("<th>");
out.print(md.getColumnName(i));
}
out.println("</tr>");
while (rs.next()) {
out.print("<tr>");
for (int i=1; i<=count; i++) {
out.print("<td>");
out.print(rs.getString(i));
}
out.println("</tr>");
}
}
out.println("</table>");
// rs.close();
} catch (SQLException ex) {
out.print("<B>" + getClass() + ": SQL Error:</B>\n" + ex);
// out.print("<pre>");
// ex.printStackTrace(out);
// out.print("</pre>");
}
finally {
DbConnectionManager.closeConnection(rs, stmt, con);
}
}
%>
</div>
</div>
</body>
</html>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment