db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Embretsen <John.Embret...@Sun.COM>
Subject Re: Trouble: Connecting Derby with cdc.
Date Tue, 25 Sep 2007 08:40:14 GMT
Renan Meneses de Andrade Franca wrote:
> Derby onli suporte DataSource method to get connect with a cdc program. 
> But Hoe can i use the DataSource to get connection with a local 
> database????????? please... i really need HELP!

Did you take a look at the SimpleApp demo included with Derby? It's in the 
demo/programs/simple/ directory in  your Derby installation. You can also view 
the source here: 

A relevant section is included below.

 From SimpleApp.java:

/* If we are using a J2ME jvm, we need to use a DataSource, otherwise
  * we can use java.sql.DriverManager to get the connection, or
  * a Datasource. This example program uses a DataSource with J2ME
  * but uses DriverManager otherwise.
  * If we were to use a DataSource for J2SE, we could use
  * the org.apache.derby.jdbc.EmbeddedDataSource, rather than the
  * org.apache.derby.jdbc.EmbeddedSimpleDataSource we need to use for J2ME.

  if( java2me )
        The connection specifies create in the DataSource settings for
        the database to be created. To remove the database,
        remove the directory derbyDB and its contents.
        The directory derbyDB will be created under
        the directory that the system property
        derby.system.home points to, or the current
        directory if derby.system.home is not set.
      ds = new org.apache.derby.jdbc.EmbeddedSimpleDataSource();
      conn = ds.getConnection(username, password);


View raw message