Subject Re: [Firebird-Java] Re:
Author Mark Rotteveel
> Ok. I have installed firebird V2.0. I open isql tool to create a database.
> I write then "CREATE DATABASE C:/db/notebook.fdb user admin password
> admin" and nothing happens. How should i correctly create a db, and maybe
> there's some GUI tool for creating and editing firebird database? After that, I
> have web app done. Working with hsql DB. And there's everything simple.

You need to quote string values like the database filename, username and password with a single quote. For more information on database creation, refer to the quickstart:
http://www.firebirdsql.org/manual/qsg2-databases.html#qsg2-databases-creating

BTW: Why are you using Firebird 2.0? Firebird 2.1 is the latest stable release.

FlameRobin is a good admin tool, but I think you can better ask on the Firebird-tools list (http://www.firebirdsql.org/index.php?op=lists#fb-tools)

If you are using Eclipse, you might also look at the Firebird Eclipse DTP implementation ( http://www.lawinegevaar.nl/firebird ), but that plugin is still a little rough around the edges (I hope to release an incremental improvement somewhere this month).

> i have jdbc properties file:
>
> jdbc.username=sa
> jdbc.password=
> jdbc.url=jdbc:hsqldb:file:/C:/Program Files/Apache Software

You of course will need to replace these with the relevant username and password for Firebird.

The basic firebird url is jdbc:firebirdsql://<hostname><port>/<path to db OR db-alias>

> Foundation/Tomcat 6.0/webapps/springapp/WEB-INF/classes/data/timexdb
>
> i have servlet.xml file with such bean:
>
> <bean id="dataSource"
>
> class="org.springframework.jdbc.datasource.DriverManagerDataSource">

Firebird also has its own DataSource implementations, you might want to try them as well.

> <property name="driverClassName" value="org.hsqldb.jdbcDriver" />

You will need to replace this with the firebird driver org.firebirdsql.jdbc.FBDriver (I think, double check that)

> <!--property name="url"
> value="jdbc:hsqldb:hsql://localhost:9005/timex" /-->
> <property name="url" value="${jdbc.url}" />
> <property name="username" value="${jdbc.username}"/>
> <property name="password" value="${jdbc.password}"/>
> </bean>
>
> <bean id="entityManagerFactory"
>
> class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" >
> <property name="dataSource" ref="dataSource" />
> <property name="jpaVendorAdapter">
> <bean
>
> class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">

I don't know if there is Firebird support in spring-JPA.

> <property name="database" value="HSQL" />
> <property name="showSql" value="true" />
> </bean>
> </property>
> </bean>
>
> and i have such code, in DAO classes to comunicate with DB using
> entityManager:
>
> private EntityManager em;
>
> @PersistenceContext
> public void setEntityManager(EntityManager em) {
> this.em = em;
> }
>
> public EntityManager getEntityManager() {
> return this.em;
> }
> public void saveNote(Note note) {
> em.merge(note);
> }
>
> public List getNotes(String addedby) {
> return em.createQuery(
> "select t from Note t where t.addedby = ?1 ORDER BY
> t.title").setParameter(1,
> addedby)
> .getResultList();
> }

As long as you use a JPA provider with Firebird support, that should work. I know that Hibernate has basic Firebird support, and I may have an improved Hibernate Dialect implementation lying around, but I never got around to testing it intensively.

> And i wanna know, if using firebird DB all these things will be working or
> i have to rewrite all my program.

Using JPA, you should normally not need to rewrite your programs.

--
GMX DSL: Internet-, Telefon- und Handy-Flat ab 19,99 EUR/mtl.
Bis zu 150 EUR Startguthaben inklusive! http://portal.gmx.net/de/go/dsl