Initial sqlite support.

This commit is contained in:
magenoxx 2012-01-25 02:07:23 +04:00
parent e901343aad
commit 20402f1cad
8 changed files with 68 additions and 0 deletions

View file

@ -50,6 +50,13 @@
<artifactId>trove</artifactId>
<version>1.0.2</version>
</dependency>
<dependency>
<groupId>org.sqlite</groupId>
<artifactId>sqlite</artifactId>
<version>0.5.6</version>
</dependency>
</dependencies>
<build>

View file

@ -0,0 +1,35 @@
package mage.db;
import java.sql.*;
/**
* @author noxx
*/
public class EntityManager {
public static void main(String[] args) throws Exception {
Class.forName("org.sqlite.JDBC");
Connection conn = DriverManager.getConnection("jdbc:sqlite:mage.db");
Statement stat = conn.createStatement();
stat.executeUpdate("drop table if exists users;");
stat.executeUpdate("create table users (login, password);");
PreparedStatement prep = conn.prepareStatement("insert into users values (?, ?);");
prep.setString(1, "TestUser");
prep.setString(2, "123");
prep.execute();
prep.setString(1, "TestUser2");
prep.setString(2, "12345");
prep.execute();
ResultSet rs = stat.executeQuery("select * from users;");
while (rs.next()) {
System.out.println("user = " + rs.getString("login"));
System.out.println("password = " + rs.getString("password"));
}
rs.close();
conn.close();
}
}

View file

@ -0,0 +1,11 @@
package mage.db.model;
/**
* @author noxx
*/
public class User {
private String login;
private String password;
}

3
README Normal file
View file

@ -0,0 +1,3 @@
Before building with Maven, install 3rd party libs to your repository using .bat or .sh file in
/repository folder

10
pom.xml
View file

@ -89,6 +89,16 @@
</pluginRepository>
</pluginRepositories>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.sqlite</groupId>
<artifactId>sqlite</artifactId>
<version>0.5.6</version>
</dependency>
</dependencies>
</dependencyManagement>
<properties>
<mage-version>0.8.2</mage-version>
</properties>

View file

@ -0,0 +1 @@
mvn install:install-file -DgroupId=org.sqlite -DartifactId=sqlite -Dversion=0.5.6 -Dpackaging=jar -Dfile=./org/sqlite/sqlitejdbc-v056.jar

View file

@ -0,0 +1 @@
mvn install:install-file -DgroupId=org.sqlite -DartifactId=sqlite -Dversion=0.5.6 -Dpackaging=jar -Dfile=./org/sqlite/sqlitejdbc-v056.jar

Binary file not shown.