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.

Reply via email to