-
Notifications
You must be signed in to change notification settings - Fork 0
Getting Started
ELCHILEN0 edited this page Mar 18, 2013
·
3 revisions
To start you will need to import the package com.TeamNovus.PersistenceLib into your projects workspace. This will allow you to easily access all the features of the Library.
Next choose the type of database that you wish to use. To connect to the chosen database you must provide the appropriate configuration to the database object. You should pre-register your tables before executing any operations here. Once configured you can connect and close the connection at any time!
public enum DatabaseType {
SQLite, MySQL;
}
public Database database;
public void init(DatabaseType type) {
if(type == SQLite) {
SQLiteConfiguration configuration = new SQLiteConfiguration();
configuration.setFilePath("data.db");
database = new SQLiteDatabase(configuration);
} else if(type == MySQL {
MySQLConfiguration configuration = new MySQLConfiguration();
configuration.setHost("localhost")
.setPort("3306")
.setDatabase("database")
.setUsername("root")
.setPassword("root");
database = new MySQLDatabase(configuration);
}
try {
db.registerTable(Employee.class);
} catch (TableRegistrationException e) {
e.printStackTrace();
}
database.connect();
database.close();
}Next Annotating Objects.