db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jose de Castro <jose.decas...@voxeo.com>
Subject Re: how i can create a datasource in java code when i have connection url?
Date Fri, 23 Feb 2007 17:14:19 GMT
You can create a new embedded DataSource by virtue of instantiating a 
new EmbeddedDataSource.

For example:

  EmbeddedDataSource dataSource =  new EmbeddedDataSource();
  dataSource.setDataSourceName("dsname");
  dataSource.setUser("APP");
  dataSource.setPassword("APP");
  dataSource.setDatabaseName("testdb");
  dataSource.setCreateDatabase("create");
  Connection connection = dataSource.getConnection();

You may also create a Client (Network Enabled) DataSource by creating a 
new ClientDataSource object as so:

  ClientDataSource ds = new ClientDataSource();
  ds.setServerName("localhost");
  ds.setPortNumber(1527);
  ds.setUser("APP");
  ds.setPassword("APP");
  ds.setDatabaseName("testdb");
  Connection conn = ds.getConnection();

NOTE: You can use ClientDataSourceFactory to obtain an existing JNDI 
DataSource.

Is this what you were looking for?

legolas wrote:
> Hi
> thank you for reading my post.
> is there any way to create a datasource in  java code when we have
> connection ur?
> indeed i should create a datasource to pass it to some data provider class
> and i can not use application server datasource mechanism.
>
>
> thanks.
>   

Mime
View raw message