Tag: cws_src680_qiq
User: fs      
Date: 2006/06/22 02:20:33

Modified:
   dba/connectivity/qa/connectivity/tools/HsqlDatabase.java

Log:
 some more helpers

File Changes:

Directory: /dba/connectivity/qa/connectivity/tools/
===================================================

File [changed]: HsqlDatabase.java
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/qa/connectivity/tools/HsqlDatabase.java?r1=1.2&r2=1.2.54.1
Delta lines:  +37 -6
--------------------
--- HsqlDatabase.java   6 Feb 2006 16:43:13 -0000       1.2
+++ HsqlDatabase.java   22 Jun 2006 09:20:31 -0000      1.2.54.1
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: HsqlDatabase.java,v $
  *
- *  $Revision: 1.2 $
+ *  $Revision: 1.2.54.1 $
  *
- *  last change: $Author: rt $ $Date: 2006/02/06 16:43:13 $
+ *  last change: $Author: fs $ $Date: 2006/06/22 09:20:31 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -55,8 +55,10 @@
     XMultiServiceFactory    m_orb;
     // the URL of the temporary file used for the database document
     String                  m_databaseDocumentFile;
-    // the data source belonging to the database document
+    // the database document
     XOfficeDatabaseDocument m_databaseDocument;
+    // the data source belonging to the database document
+    DataSource              m_dataSource;
     // the default connection
     XConnection             m_connection;
 
@@ -77,8 +79,8 @@
 
         m_databaseDocument = 
(XOfficeDatabaseDocument)UnoRuntime.queryInterface(
             XOfficeDatabaseDocument.class, m_orb.createInstance( 
"com.sun.star.sdb.OfficeDatabaseDocument" ) );
-        XDataSource dataSource = m_databaseDocument.getDataSource();
-        XPropertySet dsProperties = (XPropertySet)UnoRuntime.queryInterface( 
XPropertySet.class, dataSource );
+        m_dataSource = new DataSource( m_orb, 
m_databaseDocument.getDataSource() );
+        XPropertySet dsProperties = (XPropertySet)UnoRuntime.queryInterface( 
XPropertySet.class, m_databaseDocument.getDataSource() );
         dsProperties.setPropertyValue("URL", "sdbc:embedded:hsqldb");
 
         XStorable storable = (XStorable)UnoRuntime.queryInterface( 
XStorable.class, m_databaseDocument );
@@ -165,6 +167,28 @@
         }
     }
 
+    /** drops the table with a given name
+
+        @param _name
+            the name of the table to drop
+        @param _ifExists
+            TRUE if it should be dropped only when it exists.
+    */
+    public void dropTable( String _name, boolean _ifExists ) throws 
SQLException
+    {
+        String dropStatement = "DROP TABLE \"" + _name;
+        if ( _ifExists )
+            dropStatement += "\" IF EXISTS";
+        executeSQL( dropStatement );
+    }
+
+    public void createTable( HsqlTableDescriptor _tableDesc, boolean 
_dropIfExists ) throws SQLException
+    {
+        if ( _dropIfExists )
+            dropTable( _tableDesc.getName(), true );
+        createTable( _tableDesc );
+    }
+
     /** creates a table
      */
     public void createTable( HsqlTableDescriptor _tableDesc ) throws 
SQLException
@@ -182,7 +206,7 @@
                 createStatement += ", ";
 
             createStatement += "\"" + columns[i].Name;
-            createStatement += "\"" + columns[i].TypeName;
+            createStatement += "\" " + columns[i].TypeName;
 
             if ( columns[i].NotNull )
                 createStatement += " NOT NULL";
@@ -212,6 +236,13 @@
     public String getDocumentURL()
     {
         return m_databaseDocumentFile;
+    }
+
+    /** returns the data source belonging to this database
+    */
+    public DataSource getDataSource()
+    {
+        return m_dataSource;
     }
 
     protected void finalize() throws Throwable




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to