2 Replies Latest reply on Oct 20, 2003 9:29 AM by ottomix

    Oracle JDBC table names

      I have an Oracle 8.1.7 database. It supports longer table names (longer, anyway, than Oracle used to be happy with, if I remember rightly). The JDBC driver also is happy with longer table names (I use it in Eclipse and everything works fine).

      When I try it in JBoss, however, JBoss mangles the names of the databases horribly in realizing EJB-QL when the combined schema.tablename is longer than about 30 (I haven't established the absolute limit yet). I've tried this with various versions of JBoss up to 3.2.1; all do the same.

      First, why does it do that? If the JDBC driver and Oracle are happy, why should JBoss intrude upon their bliss?

      Second, what can I do about it? Can someone point me to a class where I can start poking around and create my own patch for this issue? Is this of interest to anyone else, that I might submit it once done?

      Thanks, all!

        • 1. Re: Oracle JDBC table names

          Wrong forum.

          <alias-max-length>
          in conf/standardjbosscmp-jdbc.xml

          Regards,
          Adrian

          • 2. Re: Oracle JDBC table names
            ottomix

            This is because the fixTableName method of the org.jboss.ejb.plugins.cmp.jdbc.SQLUtil class uses the DatabaseMetaData class to establish the max table name length.

            Here is an excerpt from the code:

            public static String fixTableName(String tableName, DataSource dataSource) throws DeploymentException {

            Connection con = null;

            try {
            con = dataSource.getConnection();
            DatabaseMetaData dmd = con.getMetaData();

            // fix length
            int maxLength = dmd.getMaxTableNameLength();

            if(maxLength > 0 && tableName.length() > maxLength) {
            CRC32 crc = new CRC32();
            crc.update(tableName.getBytes());

            String nameCRC = Long.toString(crc.getValue(), 36);
            tableName = tableName.substring(
            0,
            maxLength - nameCRC.length() - 2);
            tableName += "_" + nameCRC;
            }
            }


            The oracle.jdbc.OracleDatabaseMetaData implements getMaxTableNameLength as follows:

            public int getMaxTableNameLength()
            throws SQLException
            {
            connection.trace("getMaxTableNameLength");
            return 30;
            }

            So the absolute limit is 30 as you suspected.

            I am encountering the same problem when connecting to the Oracle database with a user that has to view tables in another schema.

            I would like to know how to tell JBoss the schema name to qualify table names with, but have yet to figure out how to do this.