Eu uso o Apache Derby em um projeto e ele funciona muito bem.
Estou colando abaixo o fonte da classe que faz a conexão com o Derby
[code]package postgeoolap.core.metadata;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import javax.swing.JOptionPane;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import postgeoolap.core.i18n.Local;
import postgeoolap.core.util.Utils;
public class MetadataConnection
{
private static Connection connection;
private static Log log = LogFactory.getLog(MetadataConnection.class);
/**
* Note: does not throw an exception, freeing user classes to handle it,
* because only once (singleton pattern) there will be a chance of exception
*
* @return a connection to metadata database
*/
public static Connection connection()
{
if (connection == null)
{
try
{
Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
String directory =
Utils.getPostGeoOlapDirectory() + "metadata";
connection = DriverManager.getConnection(
"jdbc:derby:" + directory + ";create=true", "APP", "APP");
}
catch (ClassNotFoundException e)
{
log.error(e.getMessage(), e);
JOptionPane.showMessageDialog(null, Local.getString("error.derby_driver_not_found"));
}
catch (SQLException e)
{
log.error(e.getMessage(), e);
JOptionPane.showMessageDialog(null, Local.getString("error.cannot_connect_metadata"));
}
}
return connection;
}
}[/code]
Abaixo, um método que utiliza a classe MetadataConnection listada acima para submeter uma consulta:
[code]
public void clearEmptyCubes() throws MetadataException
{
Connection connection = MetadataConnection.connection();
String sql =
"DELETE FROM cube " +
" WHERE cubecode NOT IN ( " +
" SELECT cubecode FROM dimension)";
try
{
Statement statement = connection.createStatement();
statement.execute(sql);
log.info(Local.getString("message.empty_cubes_deleted"));
}
catch (SQLException e)
{
String msg = Local.getString("error.deleting_empty_cubes");
log.error(msg + ": " + e.getMessage());
throw new MetadataException(msg, e);
}
}[/code]
Você pode conseguir o fonte inteiro do projeto usando um cliente Subversion em https://postgeoolap.svn.sourceforge.net/svnroot/postgeoolap