Results for tag "database"

2 Articles

Hibernate uses wrong schema during schema validation

Recently I struggled upon the same problem, this guy described. Our Oracle database instance contains multiple schematics with almost the same structure. Every developer has it’s own schema for unit and integration tests. On application startup the Hibernate schema validator calls the DatabaseMetaData.getTables() for every linked entity. The method returns the first table which could be found in any schema. The returned tables are by default ordered by schema name. Side node: I would expect that the home schema of the current user would be prefered. This leads to situation that sometimes the validation fails: a user has already migrated his own schema (schema name app_user_unittest) but the schema for the build server (schema name app_build_unittest) still has the old schema version.

Overwriting DatabaseMetaData.getTables() method is not possible as it resides in the Oracle JDBC driver. Instead, you can use the environment variable hibernate.default_schema which points to to prefered schema. Depending on your development environment, the variable could be set during application startup by the application itself or by a system property through your application server.

Use Confluence Play SQL Plug-in with MySQL

Play SQL is a an Atlassian Confluence plug-in for querying database tables and displaying the results inside a Confluence page. The plug-in has only native support for PostgreSQL and HSQL but other drivers can be used via a JNDI datasource.

For using MySQL with Play SQL you have to download the latest MySQL JDBC driver and extract the .jar file to your confluence/lib directory as the Tomcat container searches this path for additional libraries. Now register the new JNDI datasource by adding the following code to your confluence/conf/server.xml:

<pre>
  <Engine name="Standalone" defaultHost="localhost" debug="0">
    <Host name="localhost" debug="0" appBase="webapps" unpackWARs="true" autoDeploy="false">
      <Context path="" docBase="../confluence" debug="0" reloadable="false" useHttpOnly="true">
        <Resource
          name="jdbc/my_datasource"
          auth="Container"
          type="javax.sql.DataSource"
          url="jdbc:mysql://${SERVER}/${DATABASE}?user=${DATABASE}&amp;password=${PASSWORD}"
          driverClassName="org.gjt.mm.mysql.Driver"
          maxActive="20" maxIdle="10" maxWait="20000" />

          <Manager pathname="" />
      </Context>
    </Host>
  </Engine>
</pre>

Restart your Confluence instance (/etc/init.d/confluence restart) and open Play SQL configuration page inside the Confluence administration page. Change the Global Connection to Type: Use JNDI connection, Dialect: Generic and JNDI Name: java:comp/env/jdbc/my_datasource.
That’s it.