Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.0.5 #5

Merged
merged 4 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
Expand All @@ -30,11 +34,11 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -44,8 +48,12 @@ jobs:

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: maven

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -57,6 +65,8 @@ jobs:
#- run: |
# make bootstrap
# make release
- name: Build with Maven
run: mvn -B package --file pom.xml -Dmaven.test.skip=true

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
8 changes: 4 additions & 4 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Check w/o SNAPSHOT when "bump version"
if: ${{ contains(github.event.head_commit.message, 'bump version') }}
run: grep "<version>" pom.xml | head -1 | grep -v SNAPSHOT

- name: Set up JDK 1.8
uses: actions/setup-java@v3
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '8'
java-version: '17'
distribution: 'temurin'
cache: maven

Expand Down
53 changes: 34 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,50 @@
[![Release](https://jitpack.io/v/umjammer/vavi-sql-mdb.svg)](https://jitpack.io/#umjammer/vavi-sql-mdb)
[![Actions Status](https://github.com/umjammer/vavi-sql-mdb/workflows/Java%20CI/badge.svg)](https://github.com/umjammer/vavi-sql-mdb/actions)
[![Java CI](https://github.com/umjammer/vavi-sql-mdb/actions/workflows/maven.yml/badge.svg)](https://github.com/umjammer/vavi-sql-mdb/actions/workflows/maven.yml)
[![CodeQL](https://github.com/umjammer/vavi-sql-mdb/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/umjammer/vavi-sql-mdb/actions/workflows/codeql-analysis.yml)
[![Actions Status](https://github.com/umjammer/vavi-sql-mdb/workflows/Java%20CI/badge.svg)](https://github.com/umjammer/vavi-sql-mdb/actions)
![Java](https://img.shields.io/badge/Java-17-b07219)

# mdbtools

accessing Microsoft Access files directory and it's jdbc implementation (where clause partly works!).

## TODO
<img src="https://github.com/umjammer/vavi-sql-mdb/assets/493908/3b492010-8725-4387-b1cb-1046b8f3955b" width="120" alt="microsoft access icon"/><sub><a href="https://www.microsoft.com">© Microsoft</a></sub>

* don't forget the purpose, because I made it to read the wmp DB.
If you just do JDBC, Type 1 is fine.
* ~~jdbc-nize~~
* ~~prepared statement~~
* details (metadata, implementation of operator)
* memo: cut with 0 at the last?
* currency: implement in java Currency
* fuzzing
* https://github.com/mdbtools/mdbtools/tree/dev/src/fuzz
* https://github.com/CodeIntelligenceTesting/jazzer
* https://bazel.build/
* sarg and where clause
## Install

## License
* [maven](https://jitpack.io/#umjammer/vavi-sql-md)

[MDB Tools](https://github.com/mdbtools/mdbtools)
## Usage

> Files in libmdb, libmdbsql, and libmdbodbc are licensed under LGPL and the utilities and gui program are under the GPL, see COPYING.LIB and COPYING files respectively.
as a jdbc

```java
DriverManager.registerDriver(new vavi.sql.mdb.jdbc.Driver());
conn = DriverManager.getConnection("jdbc:mdb:" + "foo/bar.mdb");
```

## References

* https://github.com/mdbtools/mdbtools
* https://github.com/ome/ome-mdbtools
* https://github.com/JSQLParser/JSqlParser
* https://github.com/JSQLParser/JSqlParser

### License

[MDB Tools](https://github.com/mdbtools/mdbtools)

> Files in libmdb, libmdbsql, and libmdbodbc are licensed under LGPL and the utilities and gui program are under the GPL, see COPYING.LIB and COPYING files respectively.

## TODO

* don't forget the purpose, because I made it to read the wmp DB.
If you just do JDBC, Type 1 is fine.
* ~~jdbc-nize~~
* ~~prepared statement~~
* details (metadata, implementation of operator)
* memo: cut with 0 at the last?
* currency: implement in java Currency
* fuzzing
* https://github.com/mdbtools/mdbtools/tree/dev/src/fuzz
* https://github.com/CodeIntelligenceTesting/jazzer
* https://bazel.build/
* sarg and where clause
2 changes: 2 additions & 0 deletions jitpack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
jdk:
- openjdk17
27 changes: 10 additions & 17 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,14 @@

<groupId>vavi</groupId>
<artifactId>vavi-sql-mdb</artifactId>
<version>0.0.4</version>
<version>0.0.5</version>

<name>Vavi SQL MDB API</name>
<organization>
<name>vavi</name>
</organization>
<url>https://github.com/umjammer/vavi-sql-mdb</url>
<description>TODO

jdbc</description>
<description/>
<scm>
<url>https://github.com/umjammer/vavi-sql-mdb</url>
</scm>
Expand All @@ -30,17 +28,15 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<version>3.11.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
<release>17</release>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M7</version>
<version>3.2.2</version>
<configuration>
<argLine>
-Djava.util.logging.config.file=${project.build.testOutputDirectory}/logging.properties
Expand All @@ -56,7 +52,7 @@
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.9.1</version>
<version>5.10.2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand All @@ -70,9 +66,6 @@
</repository>
<repository>
<id>jsqlparser-snapshots</id>
<snapshots>
<enabled>true</enabled>
</snapshots>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
</repositories>
Expand All @@ -81,17 +74,17 @@
<dependency>
<groupId>com.github.umjammer</groupId>
<artifactId>vavi-commons</artifactId>
<version>1.1.8</version>
<version>1.1.13</version>
</dependency>
<dependency>
<groupId>com.github.jsqlparser</groupId>
<artifactId>jsqlparser</artifactId>
<version>4.5</version>
<version>4.9</version>
</dependency>
<dependency>
<groupId>com.github.albfernandez</groupId>
<artifactId>juniversalchardet</artifactId>
<version>2.4.0</version>
<version>2.5.0</version>
</dependency>

<dependency>
Expand All @@ -118,7 +111,7 @@
<dependency>
<groupId>com.code-intelligence</groupId>
<artifactId>jazzer-api</artifactId>
<version>0.13.1</version>
<version>0.22.1</version>
<scope>test</scope>
</dependency>

Expand Down
15 changes: 5 additions & 10 deletions src/main/java/vavi/apps/mdbtools/Backend.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@

import java.util.HashMap;
import java.util.Map;
import java.util.ServiceLoader;

import vavi.apps.mdbtools.Column.Type;
import vavi.apps.mdbtools.backend.AccessBackend;
import vavi.apps.mdbtools.backend.OracleBackend;
import vavi.apps.mdbtools.backend.PostgresBackend;
import vavi.apps.mdbtools.backend.SybaseBackend;


/**
Expand All @@ -26,7 +24,7 @@
public abstract class Backend {

/** */
private static Map<String, Backend> backends = new HashMap<>();
private static final Map<String, Backend> backends = new HashMap<>();

/** */
protected abstract String[] getTypeStrings();
Expand All @@ -53,11 +51,8 @@ public static Backend getInstance(String name) {
* backends
*/
static {
backends.put(AccessBackend.class.getName(), new AccessBackend());
backends.put(SybaseBackend.class.getName(), new SybaseBackend());
backends.put(OracleBackend.class.getName(), new OracleBackend());
backends.put(PostgresBackend.class.getName(), new PostgresBackend());
for (Backend backend : ServiceLoader.load(Backend.class)) {
backends.put(AccessBackend.class.getName(), backend);
}
}
}

/* */
30 changes: 16 additions & 14 deletions src/main/java/vavi/apps/mdbtools/Catalog.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
package vavi.apps.mdbtools;

import java.io.IOException;
import java.lang.System.Logger;
import java.lang.System.Logger.Level;
import java.util.ArrayList;
import java.util.List;

import vavi.util.Debug;
import static java.lang.System.getLogger;


/**
Expand All @@ -22,6 +24,8 @@
*/
class Catalog {

private static final Logger logger = getLogger(Catalog.class.getName());

enum Type {
FORM(0),
TABLE(1),
Expand Down Expand Up @@ -72,7 +76,7 @@ static Type valueOf(int value) {
this.type = type;
this.tablePage = tablePage;
this.flag = flag;
//Debug.println(StringUtil.paramString(this));
//logger.log(Level.TRACE, StringUtil.paramString(this));
}

/** */
Expand All @@ -86,9 +90,9 @@ public static List<Catalog> readCatalogs(MdbFile mdb, Type objectType) throws IO
Table table = new Table(catalog);
//catalog.dumpTable();
//table.columns.forEach(c -> Debug.print(c.name + ":" + c.type + ", "));
//Debug.println();
//logger.log(Level.TRACE, );
for (Object[] values : table.fetchRows()) {
//Debug.println("values: " + StringUtil.paramString(values));
//logger.log(Level.TRACE, "values: " + StringUtil.paramString(values));
int type = (Short) values[3];
if (objectType == Type.ANY || type == objectType.getValue()) {
catalog = new Catalog(
Expand All @@ -108,27 +112,27 @@ public static List<Catalog> readCatalogs(MdbFile mdb, Type objectType) throws IO
/** */
void dumpTable() throws IOException {
Table table = new Table(this);
//Debug.println("**** name = " + name);
//Debug.println("definition page = " + tablePage);
//Debug.println("number of datarows = " + table.numberOfRows);
//Debug.println("number of columns = " + table.numberOfColumns);
//Debug.println("number of indices = " + table.numberOfRealIndices);
//Debug.println("first data page = " + table.firstDataPage);
//logger.log(Level.TRACE, "**** name = " + name);
//logger.log(Level.TRACE, "definition page = " + tablePage);
//logger.log(Level.TRACE, "number of datarows = " + table.numberOfRows);
//logger.log(Level.TRACE, "number of columns = " + table.numberOfColumns);
//logger.log(Level.TRACE, "number of indices = " + table.numberOfRealIndices);
//logger.log(Level.TRACE, "first data page = " + table.firstDataPage);

table.readIndices();

for (int i = 0; i < table.numberOfColumns; i++) {
Column column = table.columns.get(i);

//Debug.println("column " + i + " Name: " + column.name + " Type: " + mdb.backend.getColumnTypeString(column.type) + "(" + column.size + ")");
//logger.log(Level.TRACE, "column " + i + " Name: " + column.name + " Type: " + mdb.backend.getColumnTypeString(column.type) + "(" + column.size + ")");
}

for (int i = 0; i < table.numberOfIndices; i++) {
Index index = table.indices.get(i);
index.dump(table);
}
if (table.usageMap != null) {
Debug.println("pages reserved by this object");
logger.log(Level.DEBUG, "pages reserved by this object");
int pgnum = mdb.read32Bit(table.usageMap, 1);
// the first 5 bytes of the usage map mean something
int columnNumber = 0;
Expand Down Expand Up @@ -163,5 +167,3 @@ public String toString() {
return getClass().getName() + ": " + type + ", " + name;
}
}

/* */
Loading