1 Reply Latest reply on Jan 11, 2010 5:43 AM by Wolfgang Knauf

    How create table from bean?

    Konstantin Domoratskyy Newbie

      Hi,

       

      how can I first test whether a table exists and second if it doesn't exists to create it?

       

      If I run my entity bean it works only if a corresponding table already exists. It fails if the the table doesn't exist. Is it possible to create a table from bean?

       

      Thanks in advance.

        • 1. Re: How create table from bean?
          Wolfgang Knauf Master

          Hi,

           

          the check for existence of a table can be performed by executing a SQL query. The query depends on your DBMS. For e.g. Oracle, this might be:

           

          select count(*) from all_tables where owner = 'ME' and table_name = 'MY_TABLE';

           

           

          The table could be created by executing a simple "create table" statement. But I think you have to provide more details on your use case: why does a bean have to create a table for another bean?

          Also keep in mind that in a production environment, the app should not have the rights to do DDL.

           

          Hope this helps

           

          Wolfgang