Hi,
I’'ll start with (a) and (b).
The script file that goes into your plugin ( in the , 0);’’ query in that file. The jiveVersion table is used by Wildfire to make sure that the last version of the database schema is installed. My tip is to include it as the last statement in that file, so that it only gets executed when all other statements have succeeded.
Now, when you want to make changes to your database structure (say, include a column or add an index), you create a new directory in the /src/database/ directory. You’‘ll have to name the first directory 1 (’‘one’’), the second 2, and so on. In such a directory, you include similar scripts as you did in the base directory. Instead of recreating all tables, you include scripts that change your existing table.
Finally, increase the databaseVersion value in plugin.xml. If that databaseVersion value is higher than 0, Wildfire will look which version it has installed (by querying the jiveVersion table), and executes the scripts in the subsequent directory names. (Executing the script in directory database/1/ should therefor increate the number in jiveVersion to ‘‘1’’).
What you did up to this point is make sure that Wildfire creates or updates the database structure you want to use.
Now for question ©.
You should import org.jivesoftware.database.DbConnectionManager in your plugin class. After that, you can do something like this:
java.sql.Connection con = null;
java.sql.PreparedStatement ps = null;
try
{
con = DbConnectionManager.getConnection();
ps = con.prepareStatement
(“SELECT attribute
FROM mytable
WHERE otherattribute
= ?”);
java.sql.ResultSet rs = null;
for (int value=0; value<5; value++ )
{
ps.setInt(1, value);
rs = ps.executeQuery();
while (rs.next())
{
… do something with your query result
}
rs.close();
}
ps.close();
}
catch (SQLException ex)
{
Log.warn
(“MyPluginName: Unexpected database error!”, ex);
}
finally
{
try
{
if (con != null)
{
con.close();
}
}
catch (SQLException ex)
{
Log.warn
(“MyPluginName: Couldn’'t close the connection!”, ex);
}
}
(I didn’'t compile this code, forgive me any errors).
As for your last question (d), the DbConnectionManager makes use of the connection pool you configured when you performed the initial setup of Wildfire. You can reconfigure those settings in wildfire.xml, but you probably have to restart the server for those changes to take effect.