-
Notifications
You must be signed in to change notification settings - Fork 47
Getting started
Now that we're trying to use the Anima database, the Anima is based on Java8, so you have to be sure that Java8 has been installed.
Introduce anima dependency in your pom.xml file.
<dependency>
<groupId>com.hellokaton</groupId>
<artifactId>anima</artifactId>
<version>0.3.1</version>
</dependency>compile 'com.hellokaton:anima:0.3.1'Now that you've completed the configuration, try to use the newer version of dependencies and see the latest maven version number in README.
Below are the MySQL, SQLite, H2 configuration example, in a production environment, you can give open method is passed a DataSource instance.
// MySQL
Anima.open("jdbc:mysql://127.0.0.1:3306/demo", "root", "123456");
// SQLite
Anima.open("jdbc:sqlite:./demo.db", null, null);
// H2
Anima.open("jdbc:h2:file:~/demo;FILE_LOCK=FS;PAGE_SIZE=1024;CACHE_SIZE=8192", "sa", "");Here will create a global
Sql2oinstance (Sql2o support for database operations, Anima modified the part of the source)
We usually use log output during development. Anima uses the SLF4j method, so you only need to add specific log implementations, such as adding logback.
Add Dependency
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
</dependency>Set the log output SQL to print and configure logback.xml
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<logger name="org.sql2o" level="debug"/>
<root level="INFO">
<appender-ref ref="STDOUT" />
</root>
</configuration> Well, the log configuration is OK, don't forget to add your database driver.
Next we begin to Create a Model to operate the database.
Contributing
Documentation
- Getting started
- Create Model
- Query DB
- Save to DB
- Updates and Deletes
- Transaction
- Integration with Spring
- Advanced Usage
Other resources
中文文档