Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » Scout with SQLite(Is it possible to use SQLite as database)
Scout with SQLite [message #1099778] Mon, 02 September 2013 07:40 Go to next message
Robin Hunger is currently offline Robin HungerFriend
Messages: 6
Registered: August 2013
Junior Member
Hello,

I'm using SQLite for a small project and want to use Scout.

Is it possible to integrate SQLite into a Scout application? I have tried the tutorials and there was also a tutorial for other Databases. Unfortunatly there is no checkbox for SQLite in the Technology section.

With Regards,
Robin Hunger
Re: Scout with SQLite [message #1099791 is a reply to message #1099778] Mon, 02 September 2013 08:04 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
Have you checked this?
How to write a jdbc connection bundle
Re: Scout with SQLite [message #1100534 is a reply to message #1099791] Tue, 03 September 2013 08:24 Go to previous messageGo to next message
Robin Hunger is currently offline Robin HungerFriend
Messages: 6
Registered: August 2013
Junior Member
Thank you for your quick response. This was exactly what I was looking for. I'm sorry for missing this part of the tutorial.
Re: Scout with SQLite [message #1100546 is a reply to message #1100534] Tue, 03 September 2013 08:33 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
It is OK.

Because it is hard to provide a good overview of the wiki, I prefer you ask a quick question in the forum rather than losing you time or giving up Scout.

Do not hesitate to ask questions in the forum !
Re: Scout with SQLite [message #1700682 is a reply to message #1100546] Mon, 06 July 2015 12:52 Go to previous messageGo to next message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 573
Registered: October 2012
Location: Bern, Switzerland
Senior Member
I know this is an old thread, but over the weekend I've tried writing a small Scout application to visualise an Sqlite DB I have at home.

I've read the How to article linked above and am confused:
Under step 7.1 on writing a fragment it says: Set Plug-in ID to system.bundle (this is important!)

However, after step 13 where the Manifest.MF content is listed, the corresponding line says:
Fragment-Host: org.eclipse.scout.rt.server
not
Fragment-Host: system.bundle
which is the result of following step 7.1.

Anyway, I've tried both but the result is the same. I've created the Fragment, I've added the Fragment to the server.product dependencies and resynchronised it. My Manifest file looks as follows:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Sqlite jdbc connector
Bundle-SymbolicName: demo.sqlite.fragment
Bundle-Version: 3.8.10.1
Fragment-Host: org.eclipse.scout.rt.server (I've also tried using system.bundle here but it doesn't make a difference)
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-ClassPath: lib/sqlite-jdbc-3.8.10.1.jar


Then I've created an SqliteSqlService that looks as follows:
public class SqliteSqlService extends AbstractSqlService {

  @Override
  protected String getConfiguredJdbcDriverName() {
    return "org.sqlite.JDBC";
  }

  @Override
  protected String getConfiguredJdbcMappingName() {
    return "jdbc:sqlite:D:\\\\workspaces\\\\demo\\\\database\\\\sqlite.db3";
  }
}


However, whenever I try to access the DB using SQL.select("SELECT FIELD_A, FIELD_B FROM MYTABLE") I receive the following exception:
java.lang.ClassNotFoundException: org.sqlite.JDBC cannot be found by org.eclipse.scout.rt.server_4.0.100.20140910-0600

Did I miss a step? I've checked, and the downloaded jar does contain /sqlite/org/JDBC.java, so I guess this is a classpath issue, but fail to see where I went wrong.
Re: Scout with SQLite [message #1700686 is a reply to message #1700682] Mon, 06 July 2015 13:10 Go to previous messageGo to next message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 573
Registered: October 2012
Location: Bern, Switzerland
Senior Member
Ok, I've narrowed it down and the problem above might have to do with the fact that I tried to use a standalone application (as described here).

If I disable the standalone mode and use separate client and server applications, I get a different behaviour:
After trying to use SQL.select() I get an endless loop of:

!ENTRY org.eclipse.scout.rt.server 1 0 2015-07-06 15:05:59.434
!MESSAGE org.eclipse.scout.rt.server.services.common.jdbc.internal.pool.SqlConnectionPool.leaseConnection(SqlConnectionPool.java:104) created jdbc connection org.sqlite.SQLiteConnection@a96023

!ENTRY org.eclipse.scout.rt.server 2 0 2015-07-06 15:05:59.434
!MESSAGE org.eclipse.scout.rt.server.services.common.jdbc.internal.pool.SqlConnectionPool.leaseConnection(SqlConnectionPool.java:129) closing dirty connection: org.sqlite.SQLiteConnection@a96023

So instead of just the one question I now have two:

  • How do I fix this endless connection loop? Do I need to write my own Sqlite bundle instead of just using the Fragment approach?
  • How to I make the Sqlite fragment usable in a standalone application which combines server and client into one application?

Re: Scout with SQLite [message #1700688 is a reply to message #1700686] Mon, 06 July 2015 13:19 Go to previous messageGo to next message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 573
Registered: October 2012
Location: Bern, Switzerland
Senior Member
Ok, I'm making progress debuggin the first issue: Apparently the default SqlStyle is OracleSqlStyle which uses "SELECT 1 FROM DUAL" in OracleSqlStyle.testConnection() which is not supported by Sqlite. I'll look into this and report my findings.
Re: Scout with SQLite [message #1700697 is a reply to message #1700688] Mon, 06 July 2015 14:09 Go to previous message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 573
Registered: October 2012
Location: Bern, Switzerland
Senior Member
Ok, I've solved both problems:

  • for the first I really needed my own SqliteSqlStyle (see below), which made me change from the fragment approach to the bundle approach
  • for the standalone application I had forgotten to add the new fragment (now bundle) to the client.product, because I had done a "add all necessary plugins" before adding my own SQL service.

Sorry for wasting everyone's time, but I hope it might save others from the same issue.

Here are my two classes:
public class AbstractSqliteSqlService extends AbstractSqlService {

	  @Override
	  protected String getConfiguredJdbcDriverName() {
	    return "org.sqlite.JDBC";
	  }

	  @Override
	  protected String getConfiguredJdbcMappingName() {
	    return "jdbc:sqlite:[file]";
	  }

	  @Override
	  protected Class<? extends ISqlStyle> getConfiguredSqlStyle() {
	    return SqliteSqlStyle.class;
	  }

}


public class SqliteSqlStyle extends AbstractSqlStyle {
  private static final long serialVersionUID = 1L;

  @Override
  public String getConcatOp() {
    return "||";
  }

  @Override
  public String getLikeWildcard() {
    return "%";
  }

  @Override
  protected int getMaxListSize() {
    return MAX_LIST_SIZE;
  }

  @Override
  public boolean isLargeString(String s) {
    return (s.length() > MAX_SQL_STRING_LENGTH);
  }

  @Override
  public boolean isBlobEnabled() {
    return true;
  }

  @Override
  public boolean isClobEnabled() {
    return true;
  }

  @Override
  public void testConnection(Connection conn) throws SQLException {
    Statement testStatement = null;
    try {
      testStatement = conn.createStatement();
      testStatement.execute("SELECT 1");
    }
    finally {
      if (testStatement != null) {
        try {
          testStatement.close();
        }
        catch (Throwable t) {
        }
      }
    }
  }

}

[Updated on: Mon, 06 July 2015 14:09]

Report message to a moderator

Previous Topic:How to use the template?
Next Topic:Multi Modul - Menu Extension
Goto Forum:
  


Current Time: Thu Apr 18 05:24:42 GMT 2024

Powered by FUDForum. Page generated in 0.02523 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top