How to install SJDB:
There are a few methods to install SJDB
Maven
Step 1: Include SJDB to your pom.xml file:
<dependency>
<groupId>io.github.demnetwork</groupId>
<artifactId>sjdb</artifactId>
<version>1.0.0</version>
</dependency>
Step 2: Install via command line:
Classpath
Step 1: Download SJDB here
Step 2: Add sjdb.jar to your project's classpath . This involves adding it to your IDE's project settings or specifying it on the command line when compiling and running your Java code (see examples below).
Step 3: Complie & Execute code:
javac -cp "path/to/sjdb-1.0.0.jar:." YourClass.java
java -cp "path/to/sjdb-1.0.0.jar:." YourClass
Reflection
Step 1: Download SJDB here
Step 2: Move your SJDB to ./SJDB/ (optional)
Step 3: Create the code(the snippet below supposes the sjdb.jar is at ./SJDB/sjdb.jar):
import java.io.*;
import java.lang.reflect.*;
import java.net.*;
import java.util.*;
public class Main {
private static int bn = 0;
public static void main(String[] args) throws Exception {
File f = new File("./SJDB/sjdb.jar"); // Get File Object
if (!f.exists()) {
throw new Error("Cannot find SJDB jar file"); // Throw error if file is not found
}
URLClassLoader cl = new URLClassLoader(new URL[] { f.toURI().toURL() }); // Create a class loader
Class<?> runtimeClass = cl.loadClass("io.github.demnetwork.sjdb.internal.SJDBRuntime"); // Get the SJDBRuntime class
bn = ((Integer) runtimeClass.getMethod("getBuildNumber").invoke(null)).intValue(); // Get the Build Number from SJDBRuntime
if (bn != 1) {
cl.close(); // Close URLClassLoader
throw new Error("Incompatible SJDB Version."); // Throw error due to incompatible version
}
//Load classes
Class<?> databaseManagerClazz = cl.loadClass("io.github.demnetwork.sjdb.DatabaseManager"); // Example: Loads Database manager class
//Do something
Object databaseManager = databaseManagerClazz.getConstructor().newInstance(); // Example: Creation of DatabaseManager instance
Object dataBase = databaseManagerClazz.getMethod("access", String.class, String.class, String.class).invoke(databaseManager, "path/to/database.sdb", "Username", "password"); // Access the database
}
}
Step 4 Compile & Execute:
How to install SJDB:
There are a few methods to install SJDB
Maven
Step 1: Include SJDB to your
pom.xmlfile:Step 2: Install via command line:
Classpath
Step 1: Download SJDB here
Step 2: Add
sjdb.jarto your project'sclasspath. This involves adding it to your IDE's project settings or specifying it on the command line when compiling and running your Java code (see examples below).Step 3: Complie & Execute code:
Reflection
Step 1: Download SJDB here
Step 2: Move your SJDB to
./SJDB/(optional)Step 3: Create the code(the snippet below supposes the sjdb.jar is at
./SJDB/sjdb.jar):Step 4 Compile & Execute: