Return-Path: X-Original-To: apmail-activemq-users-archive@www.apache.org Delivered-To: apmail-activemq-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C4F5C9268 for ; Thu, 29 Mar 2012 14:57:56 +0000 (UTC) Received: (qmail 81119 invoked by uid 500); 29 Mar 2012 14:57:56 -0000 Delivered-To: apmail-activemq-users-archive@activemq.apache.org Received: (qmail 81091 invoked by uid 500); 29 Mar 2012 14:57:56 -0000 Mailing-List: contact users-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@activemq.apache.org Delivered-To: mailing list users@activemq.apache.org Received: (qmail 81082 invoked by uid 99); 29 Mar 2012 14:57:56 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 29 Mar 2012 14:57:56 +0000 X-ASF-Spam-Status: No, hits=3.0 required=5.0 tests=FORGED_YAHOO_RCVD,SPF_NEUTRAL,URI_HEX X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [216.139.250.139] (HELO joe.nabble.com) (216.139.250.139) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 29 Mar 2012 14:57:51 +0000 Received: from [192.168.236.139] (helo=joe.nabble.com) by joe.nabble.com with esmtp (Exim 4.72) (envelope-from ) id 1SDGn4-0006fk-7w for users@activemq.apache.org; Thu, 29 Mar 2012 07:57:30 -0700 Date: Thu, 29 Mar 2012 07:57:30 -0700 (PDT) From: mikmela To: users@activemq.apache.org Message-ID: <1333033050236-4515693.post@n4.nabble.com> In-Reply-To: <1332614997346-4501897.post@n4.nabble.com> References: <1332614997346-4501897.post@n4.nabble.com> Subject: Re: how to make activemq switch to JDBCPersistenceAdapter in source code? MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org There are many ways to do it, but steps are 1. Create a datasource 2. Set it on JDBCPersistenceAdapter object. 3. Set PersistenceAdapter object on the broker instance... Below code for illustration only... protected PersistenceAdapter createJDBCPersistenceAdapter(DataSource ds, boolean createOnStartup) { JDBCPersistenceAdapter persistenceAdapter = null; .... persistenceAdapter = new JDBCPersistenceAdapter(); persistenceAdapter.setDataSource(ds); persistenceAdapter.setCreateTablesOnStartup(createOnStartup); return persistenceAdapter; } protected void configureJDBC() { DataSource ds = createDataSource(); PersistenceAdapter persistenceAdapter = createJDBCPersistenceAdapter(ds, false); try { this.broker.setPersistenceAdapter(persistenceAdapter); } catch ( IOException ex ) { throw new Exception ( "Failed to set JDBC: " + ex.toString()); } } protected DataSource createDataSource(String url, String driverFQN, String user, String password) { BasicDataSource ds = new BasicDataSource(); ds.setUsername(user); ds.setPassword(password); ds.setDriverClassName(driverFQN);//"oracle.jdbc.driver.OracleDriver"); ds.setUrl(url);//"jdbc:oracle:thin:@//haha:1521/haha1"); ds.setPoolPreparedStatements(true); return ds; } -- View this message in context: http://activemq.2283324.n4.nabble.com/how-to-make-activemq-switch-to-JDBCPersistenceAdapter-in-source-code-tp4501897p4515693.html Sent from the ActiveMQ - User mailing list archive at Nabble.com.