Skip to content

Commit

Permalink
- Updated readme to show information regarding Oracle
Browse files Browse the repository at this point in the history
 - Added filter support for Oracle
 - Adding preliminary View support for Oracle
 - Fixing SQL issues with Oracle impl
 - Refactored tests
  • Loading branch information
SubiyaCryolite committed Aug 3, 2017
1 parent 7effdcb commit d4b3d24
Show file tree
Hide file tree
Showing 20 changed files with 270 additions and 137 deletions.
4 changes: 4 additions & 0 deletions src/test/java/_oracleSetup.txt → Oracle Basic Setup.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
Reference point for fellow n00bs

create tablespace jds_tabspace datafile 'jds_tabspace.dat' size 10M autoextend on;
create temporary tablespace jds_tabspace_temp tempfile 'jds_tabspace_temp.dat' size 5M autoextend on;

create user jds identified by jds default tablespace jds_tabspace temporary tablespace jds_tabspace_temp

grant create session to jds;
grant create table to jds;
grant create view to jds;
grant create procedure to jds;
grant create trigger to jds;

grant unlimited tablespace to jds;
35 changes: 28 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ The API currently supports the following Relational Databases, each of which has
| MySQL |5.7.14 | [Official Site](https://www.mysql.com/downloads/) | [com.mysql.cj.jdbc.Driver](https://mvnrepository.com/artifact/mysql/mysql-connector-java)|
| Microsoft SQL Server | 2008 R2 | [Official Site](https://www.microsoft.com/en-us/sql-server/sql-server-downloads) | [com.microsoft.sqlserver](https://mvnrepository.com/artifact/com.microsoft.sqlserver/sqljdbc4)|
| SQLite | 3.16.1 | [Official Site](https://www.sqlite.org/) | [org.sqlite.JDBC](https://mvnrepository.com/artifact/org.xerial/sqlite-jdbc)|

| Oracle | 11g Release 2 | [Official Site](http://www.oracle.com/technetwork/database/database-technologies/express-edition/overview/index.html) | [oracle.jdbc.driver.OracleDriver](https://mvnrepository.com/artifact/com.oracle/ojdbc6/12.1.0.1-atlassian-hosted)|

# 1 How it works

Expand Down Expand Up @@ -397,7 +397,7 @@ public class JdsDbPostgreSqlmplementation extends JdsDbPostgreSql {
@Override
public Connection getConnection() throws ClassNotFoundException, SQLException {
Class.forName("org.postgresql.Driver");
return DriverManager.getConnection("jdbc:postgresql://127.0.0.1:5432/DB_NAME", "DB_USER", "DB_PASSWORD");
return DriverManager.getConnection("jdbc:postgresql://127.0.0.1:5432/DATABASE", "USER_NAME", "PASSWORD");
}
}

Expand All @@ -411,6 +411,7 @@ jdsDb.init();
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;

public class JdsDbMySqlImplementation extends JdsDbMySql {

Expand All @@ -419,13 +420,12 @@ public class JdsDbMySqlImplementation extends JdsDbMySql {
Class.forName("com.mysql.cj.jdbc.Driver");
Properties properties = new Properties();
properties.put("user", "USER_NAME");
properties.put("password", "USER_PASSWORD");
properties.put("password", "PASSWORD");
properties.put("autoReconnect","true");
properties.put("allowMultiQueries","false");
properties.put("useSSL","false");
properties.put("rewriteBatchedStatements","false");//known to cause problems with saves
properties.put("rewriteBatchedStatements","true");
properties.put("continueBatchOnError","true");
return DriverManager.getConnection("jdbc:mysql://localhost:3306/jds?", properties);
return DriverManager.getConnection("jdbc:mysql://localhost:3306/DATABASE?", properties);
}
}

Expand All @@ -446,7 +446,7 @@ public class JdsDbTransactionalSqllmplementation extends JdsDbTransactionalSql {
@Override
public Connection getConnection() throws ClassNotFoundException, SQLException {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
return DriverManager.getConnection("jdbc:sqlserver://127.0.0.1\\DB_INSTANCE;databaseName=DB_NAME", "DB_USER", "DB_PASSWORD");
return DriverManager.getConnection("jdbc:sqlserver://127.0.0.1\\DB_INSTANCE;databaseName=DATABASE", "USER_NAME", "PASSWORD");
}
}

Expand All @@ -455,6 +455,27 @@ public class JdsDbTransactionalSqllmplementation extends JdsDbTransactionalSql {
JdsDb jdsDb = new JdsDbTransactionalSqllmplementation();
jdsDb.init();
```
#### Oracle Example
```java
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;


public class JdsDbOracleImplementation extends JdsDbOracle {

@Override
public Connection getConnection() throws ClassNotFoundException, SQLException {
Class.forName("oracle.jdbc.driver.OracleDriver");
return DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:DATABASE", "USER_NAME", "PASSWORD");
}
}

....

JdsDb jdsDb = new JdsDbOracleImplementation();
jdsDb.init();
```
#### Sqlite Example
```java
import org.sqlite.SQLiteConfig;
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ sourceCompatibility = 1.8
targetCompatibility = 1.8

group = 'io.github.subiyacryolite'
version = '3.1.12' //majorv.minorv.bugfixincrement
version = '3.2.0' //majorv.minorv.bugfixincrement
archivesBaseName = project.name
description = 'A dynamic, cross platform, high performance, ORM data-mapper. Designed to assist in rapid development and data mining'
ext.isReleaseVersion = !version.endsWith("SNAPSHOT")
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/io/github/subiyacryolite/jds/JdsDb.java
Original file line number Diff line number Diff line change
Expand Up @@ -1023,30 +1023,30 @@ public String mapEnumValues() {
public abstract String createOrAlterView(String viewName, String viewSql);

protected String getSaveOldTextValues() {
return "INSERT INTO JdsStoreOldFieldValues(EntityGuid, FieldId, Sequence, TextValue) VALUES(:entityGuid, :fieldId, :sequence, :value);";
return "INSERT INTO JdsStoreOldFieldValues(EntityGuid, FieldId, Sequence, TextValue) VALUES(:entityGuid, :fieldId, :sequence, :value)";
}

protected String getSaveOldDoubleValues() {
return "INSERT INTO JdsStoreOldFieldValues(EntityGuid, FieldId, Sequence, DoubleValue) VALUES(:entityGuid, :fieldId, :sequence, :value);";
return "INSERT INTO JdsStoreOldFieldValues(EntityGuid, FieldId, Sequence, DoubleValue) VALUES(:entityGuid, :fieldId, :sequence, :value)";
}

protected String getSaveOldLongValues() {
return "INSERT INTO JdsStoreOldFieldValues(EntityGuid, FieldId, Sequence, LongValue) VALUES(:entityGuid, :fieldId, :sequence, :value);";
return "INSERT INTO JdsStoreOldFieldValues(EntityGuid, FieldId, Sequence, LongValue) VALUES(:entityGuid, :fieldId, :sequence, :value)";
}

protected String getSaveOldIntegerValues() {
return "INSERT INTO JdsStoreOldFieldValues(EntityGuid, FieldId, Sequence, IntegerValue) VALUES(:entityGuid, :fieldId, :sequence, :value);";
return "INSERT INTO JdsStoreOldFieldValues(EntityGuid, FieldId, Sequence, IntegerValue) VALUES(:entityGuid, :fieldId, :sequence, :value)";
}

protected String getSaveOldFloatValues() {
return "INSERT INTO JdsStoreOldFieldValues(EntityGuid, FieldId, Sequence, FloatValue) VALUES(:entityGuid, :fieldId, :sequence, :value);";
return "INSERT INTO JdsStoreOldFieldValues(EntityGuid, FieldId, Sequence, FloatValue) VALUES(:entityGuid, :fieldId, :sequence, :value)";
}

protected String getSaveOldDateTimeValues() {
return "INSERT INTO JdsStoreOldFieldValues(EntityGuid, FieldId, Sequence, DateTimeValue) VALUES(:entityGuid, :fieldId, :sequence, :value);";
return "INSERT INTO JdsStoreOldFieldValues(EntityGuid, FieldId, Sequence, DateTimeValue) VALUES(:entityGuid, :fieldId, :sequence, :value)";
}

protected String getSaveOldBlobValues() {
return "INSERT INTO JdsStoreOldFieldValues(EntityGuid, FieldId, Sequence, BlobValue) VALUES(:entityGuid, :fieldId, :sequence, :value);";
return "INSERT INTO JdsStoreOldFieldValues(EntityGuid, FieldId, Sequence, BlobValue) VALUES(:entityGuid, :fieldId, :sequence, :value)";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ public interface JdsDbContract {
* correctly
* @throws SQLException when a standard SQL Exception occurs
*/
public abstract Connection getConnection() throws ClassNotFoundException, SQLException;
Connection getConnection() throws ClassNotFoundException, SQLException;
}
7 changes: 7 additions & 0 deletions src/main/java/io/github/subiyacryolite/jds/JdsDbMySql.java
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,13 @@ protected void createRefEntityOverview() {
@Override
protected void createRefOldFieldValues() {
executeSqlFromFile("sql/mysql/createStoreOldFieldValues.sql");
//allow multiple leaves you open to SLQ injection. Thus manually add these indexes here unless you want to add more files
executeSqlFromString("CREATE INDEX IntegerValues ON JdsStoreOldFieldValues(EntityGuid, FieldId, Sequence, IntegerValue);");
executeSqlFromString("CREATE INDEX FloatValues ON JdsStoreOldFieldValues(EntityGuid, FieldId, Sequence, FloatValue);");
executeSqlFromString("CREATE INDEX DoubleValues ON JdsStoreOldFieldValues(EntityGuid, FieldId, Sequence, DoubleValue);");
executeSqlFromString("CREATE INDEX LongValues ON JdsStoreOldFieldValues(EntityGuid, FieldId, Sequence, LongValue);");
executeSqlFromString("CREATE INDEX DateTimeValues ON JdsStoreOldFieldValues(EntityGuid, FieldId, Sequence, DateTimeValue);");
executeSqlFromString("CREATE INDEX TextBlobValues ON JdsStoreOldFieldValues(EntityGuid, FieldId, Sequence);");
}

@Override
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/io/github/subiyacryolite/jds/JdsDbOracle.java
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,14 @@ protected void createRefEntityOverview() {
@Override
protected void createRefOldFieldValues() {
executeSqlFromFile("sql/oracle/createStoreOldFieldValues.sql");
//allow multiple leaves you open to SLQ injection. Thus manually add these indexes here unless you want to add more files
//oracle jdbc hates semi-colons
executeSqlFromString("CREATE INDEX IntegerValues ON JdsStoreOldFieldValues(EntityGuid, FieldId, Sequence, IntegerValue)");
executeSqlFromString("CREATE INDEX FloatValues ON JdsStoreOldFieldValues(EntityGuid, FieldId, Sequence, FloatValue)");
executeSqlFromString("CREATE INDEX DoubleValues ON JdsStoreOldFieldValues(EntityGuid, FieldId, Sequence, DoubleValue)");
executeSqlFromString("CREATE INDEX LongValues ON JdsStoreOldFieldValues(EntityGuid, FieldId, Sequence, LongValue)");
executeSqlFromString("CREATE INDEX DateTimeValues ON JdsStoreOldFieldValues(EntityGuid, FieldId, Sequence, DateTimeValue)");
executeSqlFromString("CREATE INDEX TextBlobValues ON JdsStoreOldFieldValues(EntityGuid, FieldId, Sequence)");
}

@Override
Expand Down
Loading

0 comments on commit d4b3d24

Please sign in to comment.