Esempio n. 1
0
  public Database() {

    JDBCDataSource dataSource = new JDBCDataSource();
    dataSource.setUrl("jdbc:hsqldb:hsql://localhost:12350/hladdb");
    dataSource.setUser("sa");
    dataSource.setPassword("");
    jdbcTemplate = new JdbcTemplate(dataSource);
  }
Esempio n. 2
0
 /**
  * methode contient le parametre de la base de donne
  *
  * @return DataSource
  */
 private static DataSource getApplicationDataSource() {
   if (dataSource == null) {
     dataSource = new JDBCDataSource();
     dataSource.setUrl(
         "jdbc:hsqldb:file:D:\\outils_de_travail\\springsource\\workspace-sts\\location-velos\\data\\data");
     dataSource.setUser("root");
     dataSource.setPassword("root");
   }
   return dataSource;
 }
Esempio n. 3
0
  // @Test  TODO. commented out. Can't get test to work without an application server.
  public void testCreateSql2oFromJndi() throws Exception {
    System.setProperty(
        Context.INITIAL_CONTEXT_FACTORY, "org.apache.naming.java.javaURLContextFactory");
    System.setProperty(Context.URL_PKG_PREFIXES, "org.apache.naming");

    InitialContext ic = new InitialContext();

    ic.createSubcontext("java:");
    ic.createSubcontext("java:comp");
    ic.createSubcontext("java:comp/env");

    JDBCDataSource datasource = new JDBCDataSource();
    datasource.setUrl(url);
    datasource.setUser(user);
    datasource.setPassword(pass);

    ic.bind("java:comp/env/Sql2o", datasource);

    System.out.println("Datasource initialized.");

    Sql2o jndiSql2o = new Sql2o("Sql2o");

    assertTrue(jndiSql2o != null);
  }