Package nexj.core.persistence.sql

Examples of nexj.core.persistence.sql.SQLAdapter$Bind


      String sFile = getRequiredProperty("sql.file")
         .replace("${cmd}", m_sCommand)
         .replace("${ds}", database.getName());
      String sOwner = getProperty("meta.owner");
      SQLAdapter adapter = (SQLAdapter)database.getComponent().getInstance(null);
      SQLSchemaManager manager = adapter.createSchemaManager(database);

      if (sOwner != null) // some SchemaManagers (e.g. DB2) will have a different default for null
      {
         manager.setOwner((sOwner.equals(".")) ? "" : sOwner);
      }
View Full Code Here


  
            m_connection = DriverManager.getConnection(sURL, connectionProperties);
         }
         else
         {
            SQLAdapter adapter = (SQLAdapter)getDatabase().getComponent().getInstance(null);
           
            m_connection = adapter.getConnectionFactory().getConnection(adapter);
         }
      }

      return m_connection;
   }
View Full Code Here

                     {
                        continue;
                     }

                     RelationalDatabase ds = (RelationalDatabase)fragment.getDataSource();
                     SQLAdapter adapter = (SQLAdapter)ds.getComponent().getInstance(null);
                     String sDataSourceClass = ds.getDriver();

                     ref.addProperty(new J2EEProperty("name", ds.getName()));
                     ref.addProperty(new J2EEProperty("dataSource", sDataSourceClass));
                     ref.addProperty(new J2EEProperty("initialSQL", adapter.getInitialSQL()));
                     ref.addProperty(new J2EEProperty("password", fragment.getPassword()));
                     ref.addProperty(new J2EEProperty("properties",
                           PropertyUtil.toString(fragment.getPropertyHolder().getProperties())));
                     ref.addProperty(new J2EEProperty("statementCacheSize", fragment.getStatementCacheSize()));
                     ref.addProperty(new J2EEProperty("testSQL", adapter.getTestSQL()));
                     ref.addProperty(new J2EEProperty("user", fragment.getUser()));
                     ref.addProperty(new J2EEProperty("isolationLevel",
                                                      Connection.TRANSACTION_READ_COMMITTED));
                  }
View Full Code Here

                  {
                     cf = new Component(source.getName() + ".ConnectionFactory" + fragment.getSuffix(),
                        loader.getHelper().getClassObject(SysUtil.PACKAGE + ".core.persistence.sql.SQLRAConnectionFactory"),
                        Component.SINGLETON);

                     SQLAdapter adapterInstance = (SQLAdapter)component.getInstance(null);

                     cf.addPrimitivePropertyInitializer("fragment", fragment);
                     cf.addPrimitivePropertyInitializer("initialSQL", adapterInstance.getInitialSQL());
                     cf.addPrimitivePropertyInitializer("testSQL", adapterInstance.getTestSQL());
                  }

                  cf.setMetadata(loader.getMetadata());
                  fragment.setConnectionFactory(cf);
                  loader.addSingletonFixup(cf);
View Full Code Here

   public void deleteData(DataSource dataSource) throws Exception
   {
      if (dataSource instanceof RelationalDatabase)
      {
         RelationalDatabase database = (RelationalDatabase)dataSource;
         SQLAdapter adapter = (SQLAdapter)database.getComponent().getInstance(m_context);
         SQLSchemaManager manager = adapter.createSchemaManager(database);
         RelationalSchema schema = (RelationalSchema)database.getSchema();
         String sOrigFragment = m_context.getFragmentName();
         Connection connection = null;

         try
         {
            for (Iterator itr = dataSource.getFragmentIterator(); itr.hasNext();) // each fragment
            {
               m_context.setFragmentName(((Named)itr.next()).getName()); // connection for fragment

               try
               {
                  if (s_logger.isDebugEnabled())
                  {
                     s_logger.debug("Deleting data in data source \"" + dataSource.getName() + '"');
                  }

                  connection = adapter.getConnectionFactory().getConnection(adapter);
                  manager.setSQLAppender(new SQLSchemaManager.SQLConnectionAppender(connection, true));
                  manager.truncateSchema(schema);

                  if (s_logger.isDebugEnabled())
                  {
                     s_logger.debug("Deletion completed");
                  }
               }
               finally
               {
                  adapter.close(connection);
               }
            }
         }
         finally
         {
View Full Code Here

   public void dropSchema(DataSource dataSource) throws Exception
   {
      if (dataSource instanceof RelationalDatabase)
      {
         RelationalDatabase database = (RelationalDatabase)dataSource;
         SQLAdapter adapter = (SQLAdapter)database.getComponent().getInstance(m_context);
         SQLSchemaManager manager = adapter.createSchemaManager(database);
         RelationalSchema schema = (RelationalSchema)database.getSchema();
         String sOrigFragment = m_context.getFragmentName();
         Connection connection = null;

         try
         {
            for (Iterator itr = dataSource.getFragmentIterator(); itr.hasNext();) // each fragment
            {
               m_context.setFragmentName(((Named)itr.next()).getName()); // connection for fragment

               try
               {
                  connection = adapter.getConnectionFactory().getConnection(adapter);
                  manager.setSQLAppender(
                     new SQLSchemaManager.SQLConnectionAppender(connection, true));

                  if (s_logger.isDebugEnabled())
                  {
                     s_logger.debug(
                        "Dropping the schema of data source \"" + dataSource.getName() + '"');
                  }

                  manager.dropSchema(schema);

                  if (s_logger.isDebugEnabled())
                  {
                     s_logger.debug("Schema dropped");
                  }
               }
               finally
               {
                  adapter.close(connection);
               }
            }
         }
         finally
         {
View Full Code Here

   public void createSchema(DataSource dataSource) throws Exception
   {
      if (dataSource instanceof RelationalDatabase)
      {
         RelationalDatabase database = (RelationalDatabase)dataSource;
         SQLAdapter adapter = (SQLAdapter)database.getComponent().getInstance(m_context);
         SQLSchemaManager manager = adapter.createSchemaManager(database);
         RelationalSchema schema = (RelationalSchema)database.getSchema();
         String sOrigFragment = m_context.getFragmentName();
         Connection connection = null;

         try
         {
            for (Iterator itr = dataSource.getFragmentIterator(); itr.hasNext();) // each fragment
            {
               m_context.setFragmentName(((Named)itr.next()).getName()); // connection for fragment

               try
               {
                  connection = adapter.getConnectionFactory().getConnection(adapter);
                  manager.setSQLAppender(
                     new SQLSchemaManager.SQLConnectionAppender(connection, false));

                  if (s_logger.isDebugEnabled())
                  {
View Full Code Here

            continue; // skip DataSources without any Metaclasses mapped to them
         }

         importDataSourceSet.add(ds);

         SQLAdapter adapter = (SQLAdapter)ds.getComponent().getInstance(m_context);

         adapterList.add(adapter); //reference locally so not GCed
         adapter.setConnectionFactory(outCF); // override adapter's SQLConnectionFactory
      }

      importData(in, importDataSourceSet, true); // assume no data in DB
   }
View Full Code Here

      String sInitSQL = null;
      String sTestSQL;

      if (jdbcConnInfo == null)
      {
         SQLAdapter adapter = getAdapter(db);
         sInitSQL = adapter.getInitialSQL();
         sTestSQL = adapter.getTestSQL();
      }
      else
      {
         sTestSQL = jdbcConnInfo.getTestSQL();
      }
View Full Code Here

    * @param db The database.
    * @return The SQL adapter.
    */
   protected SQLAdapter getAdapter(RelationalDatabase db)
   {
      SQLAdapter adapter = (SQLAdapter)m_adapterMap.get(db);

      if (adapter == null)
      {
         adapter = (SQLAdapter)db.getComponent().getInstance(null);
         m_adapterMap.put(db, adapter);
View Full Code Here

TOP

Related Classes of nexj.core.persistence.sql.SQLAdapter$Bind

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.