-
Notifications
You must be signed in to change notification settings - Fork 3
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
Documentation & Project State #1
Comments
I know it's very late, but here's an example. It might be useful for someone else. Here is an example on how to use jLoquent:
Here are some declaration examples. Configurationpackage com.slprojects.test;
import org.jloquent.DBConfig;
import org.jloquent.DatabaseType;
public class Configuration implements DBConfig {
@Override
public DatabaseType getDatabaseType() {
return DatabaseType.MYSQL;
}
@Override
public String getHostName() {
return "databaseHostname";
}
@Override
public String getPortNumber() {
return "databasePort";
}
@Override
public String getDatabaseName() {
return "databaseName";
}
@Override
public String getUsername() {
return "databaseUsername";
}
@Override
public String getPassword() {
return "yourPassword";
}
} Model (mine is called User)package com.slprojects.test;
import org.jloquent.Model;
import java.sql.Timestamp;
public class User extends Model {
private String name;
private String email;
private String password;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public Timestamp getJoinedDate() {
return joinedDate;
}
public void setJoinedDate(Timestamp joinedDate) {
this.joinedDate = joinedDate;
}
private Timestamp joinedDate;
} Mainpackage com.slprojects.test;
import org.jloquent.Connector;
import org.jloquent.DBConfig;
public class Main {
public static void main(String[] args) {
Connector connector = Connector.getInstance();
DBConfig config = new Configuration();
connector.setDBConfig(config);
connector.open();
User user = new User();
user.setName("JohnDoe");
user.setEmail("[email protected]");
user.setPassword("123456");
user.setJoinedDate(new java.sql.Timestamp(System.currentTimeMillis()));
user.save();
}
} If everything went well, you should see the sql insert command appear in the console. NOTE: The DB driver is missing from the project. You should add the one that correspond you database type in the project depedencies. Example for MariaDB/MySQL based database: <dependencies>
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.32</version>
</dependency>
</dependencies> Also note that the project is no longer maintained, and will most likely need to update classes and add new database types in the future. But the project remains usable in the current state. |
I'm working on a fork. You can find it here: https://github.com/SofianeLasri/bjLoquent |
I like this library, but I haven't used it yet because I am not sure where to start. Is this project complete? I tried to find the documentation and I couldn't find any. Is there documentation for this project?
Thanks!
The text was updated successfully, but these errors were encountered: