Jaeksoft Pojodbc - Developer Javadoc

The JAVA library which reconciles JDBC and POJO




The JAVA library which reconciles JDBC and POJO

Start working with POJO without rewriting all your JDBC application. Without any configuration file, without any annotation, use your native SQL request with JDBC and get POJO(s).

Sample code

Firstable, you need to create a ConnectionManager. A ConnectionManager is not a connection pool. Taking a jdbc url or a datasource, the ConnectionManager just provide new connection.

 JDBCConnection connectionManager = new JDBCConnection();

Now we can start working with our database. Pojodbc take care of database connection for you. You work with a transaction to obtain a list of Pojo.

 Transaction transaction = null;
 try {
    // Obtain a new transaction from the ConnectionManager
    transaction = connectionManager.getNewTransaction(false,
    // Start a new Query
    Query query = transaction.prepare("SELECT * FROM MyTable WHERE status=?");
    query.getStatement().setString(1, "open");
    // Get the result
    List<MyPojo> myPojoList = query.getResultList(MyPojo.class));
    // do everything you need
  } finally {
    // Release the transaction
    if (transaction != null)

The only thing you have to do is to release the transaction. The best way to do that is to close the transaction in a finally clause. Pojodbc will release all Statement, ResultSet and Connection.

You dont have to maintain the transaction open to use your Pojo list.

License and copyright

Copyright (C) 2008 Emmanuel Keller / Jaeksoft

Jaeksoft Pojodbc is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Jaeksoft Pojodbc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Jaeksoft Pojodbc. If not, see http://www.gnu.org/licenses/.

Related Documentation

For overviews, tutorials, examples, guides, and tool documentation, please see: