|
|
|
|
Re: Scout with SQLite [message #1700682 is a reply to message #1100546] |
Mon, 06 July 2015 12:52 |
Urs Beeli 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 #1700697 is a reply to message #1700688] |
Mon, 06 July 2015 14:09 |
Urs Beeli 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
|
|
|
Powered by
FUDForum. Page generated in 0.02523 seconds