Skip to content

Commit

Permalink
Compatibility with H2 Database Engine
Browse files Browse the repository at this point in the history
  • Loading branch information
santteegt committed Feb 27, 2015
1 parent f3edf66 commit 3d3b20c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@
<artifactId>postgresql</artifactId>
<version>9.1-901.jdbc4</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.184</version>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -700,13 +700,19 @@ private Map<ColumnIdentifier, byte[]> applyValueToRow(TermMap tm) throws SQLExce
if(cId.equals(column)) {
log.debug("[R2RMLEngine:applyValueToRow] Value found : \""
+ rows.getString(i) +"\" (Type: "+cId.getSqlType()+")");
byte[] rawData = rows.getBytes(i);

// http://bugs.mysql.com/bug.php?id=65943
if(rawData != null &&
R2RMLProcessor.getDriverType().equals(DriverType.MysqlDriver) &&
cId.getSqlType() == SQLType.CHAR) {
rawData = rows.getString(i).getBytes();
byte[] rawData;
//H2 bug on string to hex conversion: ERROR 90003
if(R2RMLProcessor.getDriverType().equals(DriverType.H2)
&& cId.getSqlType() == SQLType.VARCHAR) {
rawData = rows.getString(i).getBytes();
} else {
rawData = rows.getBytes(i);
// http://bugs.mysql.com/bug.php?id=65943
if(rawData != null &&
R2RMLProcessor.getDriverType().equals(DriverType.MysqlDriver) &&
cId.getSqlType() == SQLType.CHAR) {
rawData = rows.getString(i).getBytes();
}
}
result.put(cId, rawData);
found = true;
Expand Down Expand Up @@ -950,7 +956,7 @@ private ResultSet constructLogicalTable(TriplesMap triplesMap)
+ triplesMap.getLogicalTable().getEffectiveSQLQuery());
ResultSet rs = null;
java.sql.Statement s = conn.createStatement(
ResultSet.HOLD_CURSORS_OVER_COMMIT, ResultSet.CONCUR_READ_ONLY);
ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
if (triplesMap.getLogicalTable().getEffectiveSQLQuery() != null) {

s.executeQuery(triplesMap.getLogicalTable().getEffectiveSQLQuery());
Expand All @@ -976,7 +982,7 @@ private ResultSet constructJointTable(ReferencingObjectMap refObjectMap)
+ refObjectMap.getJointSQLQuery());
ResultSet rs = null;
java.sql.Statement s = conn.createStatement(
ResultSet.HOLD_CURSORS_OVER_COMMIT, ResultSet.CONCUR_READ_ONLY);
ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
if (refObjectMap.getJointSQLQuery() != null) {
s.executeQuery(refObjectMap.getJointSQLQuery());
rs = s.getResultSet();
Expand All @@ -999,7 +1005,7 @@ private ResultSet constructInversionTable(String instantiation,
+ sqlQuery);
ResultSet rs = null;
java.sql.Statement s = conn.createStatement(
ResultSet.HOLD_CURSORS_OVER_COMMIT, ResultSet.CONCUR_READ_ONLY);
ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
s.executeQuery(sqlQuery);
rs = s.getResultSet();
if (rs == null)
Expand Down
1 change: 1 addition & 0 deletions src/main/java/net/antidot/sql/model/core/DriverType.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
public class DriverType {
public static DriverType MysqlDriver = new DriverType("com.mysql.jdbc.Driver");
public static DriverType PostgreSQL = new DriverType("org.postgresql.Driver");
public static DriverType H2 = new DriverType("org.h2.Driver");

private String driverName;

Expand Down

0 comments on commit 3d3b20c

Please sign in to comment.