42 lines
1.3 KiB
Java
42 lines
1.3 KiB
Java
package de.vanitasvitae.fasel;
|
|
|
|
import java.sql.SQLException;
|
|
|
|
import com.j256.ormlite.jdbc.JdbcConnectionSource;
|
|
import com.j256.ormlite.support.ConnectionSource;
|
|
import com.j256.ormlite.table.TableUtils;
|
|
import de.vanitasvitae.fasel.db.AbstractDatabase;
|
|
import de.vanitasvitae.fasel.db.entity.Account;
|
|
import de.vanitasvitae.fasel.db.entity.Contact;
|
|
import de.vanitasvitae.fasel.db.entity.XmppEntity;
|
|
import de.vanitasvitae.fasel.db.java.JavaAccountDatabase;
|
|
|
|
public class FaselDBTest {
|
|
|
|
private AbstractDatabase database;
|
|
|
|
public static void main(String[] args) throws SQLException {
|
|
FaselDBTest db = new FaselDBTest();
|
|
db.insert();
|
|
db.get();
|
|
}
|
|
|
|
public FaselDBTest() throws SQLException {
|
|
database = new JavaAccountDatabase();
|
|
}
|
|
|
|
public void insert() throws SQLException {
|
|
XmppEntity entity = new XmppEntity();
|
|
entity.setJid("hans@vader.sw");
|
|
Contact contact = new Contact(entity);
|
|
contact.setNickname("Hans Vader");
|
|
database.getContactsDao().create(contact);
|
|
}
|
|
|
|
public void get() throws SQLException {
|
|
for (Account account : database.getAccountsDao().queryForAll()) {
|
|
System.out.print(account.getAccountId() + " " + account.getJid() + " " + account.getPassword());
|
|
}
|
|
}
|
|
}
|