Создать Blueprint Hello World.
Добавить в pom.xml:
<dependencies>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.16.1</version>
</dependency>
</dependencies>
Изменить App.java:
import org.sqlite.SQLiteDataSource;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.Statement;
public class App {
public void init(){
SQLiteDataSource dataSource = new SQLiteDataSource();
dataSource.setUrl("jdbc:sqlite:test.db");
Connection connection=null;
try {
connection = dataSource.getConnection();
Statement command = connection.createStatement();
command.execute("create table mytable (name)"); // создать таблицу
// и добавить в таблицу запись
PreparedStatement command = connection.prepareStatement("insert into mytable (name) values (?)");
command.setString(1, "Hello World!");
command.executeUpdate();
}catch (Exception e) {
e.printStackTrace();
}
}
public void destroy(){
System.out.println("Bye!");
}
}
В karaf-е выполнить:
feature:repo-add pax-jdbc
feature:install pax-jdbc-sqlite
Скопировать jar-файл в папку deploy.
В папке servicemix-а появится файл test.db с таблицей mytable: