It´s possible read openfire database from custom plugin

Hi,

I´m newby in openfire and i want to know if is possible read data from openfire tables and write inside a plugin develop by me.

thank you!!

Possible, but very dangerous to write to it since OF internal caches will probably get out of sync with the database. I think you might end up with unpredictable side effects if you try to write.

Ok, But if i only read from OF database there is no problem, right?

Could you help me with the other question? is possible use Ad hoc command in my own plugin?

Thak you!!

u CAN read and write in OF database, but remember about cash - server don’t change his cash if it don’t know thet u somethin change in DB. And wtf “Ad hoc command”? =)

I think so. I am pretty sure you can route directly to your plugin, then it would simply have to handle the commands.

Sure. You can use code like this in your plugin. Look at the online docs for some of these APIs to see how to do other things.

import java.sql.Connection;
import org.jivesoftware.util.Log;

import java.sql.PreparedStatement;
import org.jivesoftware.database.DbConnectionManager; ... Connection con = DbConnectionManager.getConnection(); try {
    PreparedStatement insertStmt = con.prepareStatement("INSERT INTO ofMyTable   (foo, bar) VALUES (?, ?)");
     
    insertStmt.setString(1,    "one");
    insertStmt.setString(2,    "two");
    insertStmt.executeUpdate();
     
    DbConnectionManager.closeStatement(insertStmt);
} catch (Exception e) {
    Log.error("Error inserting record: " + e);
}