のデータソースを作成する必要があります。問題は、アプリケーションが即座に接続設定を構成し変更するように設計されていることです。私は、データソースを動的に作成し、それを使ってデータベースへの接続を開くことができる次のコードを書いています。ただし、このコードはDataDirectドライバ用に作成されたもので、OracleおよびMS SQLに接続するために使用しています。残念ながら、DataDirect Mysqlドライバは、無料バージョンではなく、商用バージョンのmysqlにのみ接続します。だから私はmysqlからconnect/jで同じタスクを達成しようとしています。 DDドライバのようにメソッド呼び出しによって外部(静的)データソース定義にある接続プロパティを設定する方法が見つかりません。どんな助けもありがとう。は、私は、データベースへの接続時に接続プールを使用する必要があるアプリケーションを持って動的にMySQLの接続/ J接続プール
BaseDataSource bds = (BaseDataSource)ds;
// Populate the DataSource
bds.setDescription("Driver Data Source");
bds.setServerName(connectUrl);
bds.setUser(userName);
bds.setPassword(password);
if (spyAttr.length() > 0) bds.setSpyAttributes(spyAttr);
// Create the PooledConnection DataSource. Pass the data source created above
// to the PooledConnection DataSource
pds = new PooledConnectionDataSource();
pds.setDescription("Pooled Data Source");
pds.setDataSourceName("myDataSource", bds);
pds.setPoolName("myPool");
pds.setInitialPoolSize(nPoolSize);
pds.setMinPoolSize(minPoolSize);
pds.setMaxPoolSize(maxPoolSize);
pds.setPropertyCycle(propCycle);
pds.setMaxIdleTime(maxIdleTime);
pds.setTracing(tracing);
// Get connection
pds.getConnection();