manywho/sql2o


sql2o is a small library, which makes it easy to convert the result of your sql-statements into objects. No resultset hacking required. Kind of like an orm, but without the sql-generation capabilities. Supports named parameters. http://sql2o.org

Download


Step 1. Add the JitPack repository to your build file

Add it in your root settings.gradle at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url 'https://jitpack.io' }
		}
	}

Add it in your settings.gradle.kts at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url = uri("https://jitpack.io") }
		}
	}

Add to pom.xml

	<repositories>
		<repository>
		    <id>jitpack.io</id>
		    <url>https://jitpack.io</url>
		</repository>
	</repositories>

Add it in your build.sbt at the end of resolvers:

 
    resolvers += "jitpack" at "https://jitpack.io"
        
    

Add it in your project.clj at the end of repositories:

 
    :repositories [["jitpack" "https://jitpack.io"]]
        
    

Step 2. Add the dependency

	dependencies {
		implementation 'com.github.manywho:sql2o:'
	}
	dependencies {
		implementation("com.github.manywho:sql2o:")
	}
	<dependency>
	    <groupId>com.github.manywho</groupId>
	    <artifactId>sql2o</artifactId>
	    <version></version>
	</dependency>

                            
    libraryDependencies += "com.github.manywho" % "sql2o" % ""
        
        

                            
    :dependencies [[com.github.manywho/sql2o ""]]
        
        

Readme


sql2o Build Status

Sql2o is a small java library, with the purpose of making database interaction easy. When fetching data from the database, the ResultSet will automatically be filled into your POJO objects. Kind of like an ORM, but without the SQL generation capabilities.

Examples

Check out the sql2o website for examples.

Performance

A key feature of sql2o is performance. The following metrics were based off the Dapper.NET metrics. Note that typical usage can differ from optimal usage for many frameworks. Depending on the framework, typical usage may not involve writing any SQL, or it may map underscore case to camel case, etc.

Performance of SELECT

Execute 1000 SELECT statements against a DB and map the data returned to a POJO. Code is available here.

Method | Duration | ------------------------------------------------------------------- | ---------------------- | Hand coded <code>ResultSet</code> | 60ms | Sql2o | 75ms (25% slower) | Apache DbUtils | 98ms (63% slower) | JDBI | 197ms (228% slower) | MyBatis | 293ms (388% slower) | jOOQ | 447ms (645% slower) | Hibernate | 494ms (723% slower) | Spring JdbcTemplate | 636ms (960% slower) |

Contributing

Want to contribute? Awesome! Here's how to set up.

Coding guidelines.

When hacking sql2o, please follow these coding guidelines.

Download oracle driver

To run the oracle database tests it is necessary to download the oracle jdbc driver manually, and register it with maven. Oracle does not have a public repository where maven can download the driver automatically. Note that public repositories do exist, but they are all technically illegal.

  • Download the ojdbc6.jar version 11.2.0.3 from here
  • Install it into your local maven repo by running this command:
mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0.3 -Dpackaging=jar -Dfile=ojdbc6.jar -DgeneratePom=true