Questions tagged [jdbi]

jDBI is an extension library over standard JDBC, to make writing relational database access more convenient (and correct!) from Java.

jDBI is a Java library that builds on JDBC to offer more convenient, light-weight access to relational databases. It aims to make database access more convenient and correct by building simple abstractions on top of raw JDBC.

384 questions
4
votes
1 answer

How to run sql script file using JDBI

I am using jdbi to make connection to db and execute sql command. dbi = new DBI("jdbc:mysql://"+dbHostName+"/"+dbName, "root", ""); dbi.withHandle(new HandleCallback() { @Override public Object withHandle(Handle handle)…
vaibhav.g
  • 729
  • 1
  • 9
  • 28
4
votes
3 answers

JDBI No Mapper Registered

I am evaluating JDBI as a possible alternative to Spring JDBC and MyBatis but encountering some issues. I am using JDBI with Spring Boot 1.2.5 so Spring 4. I am getting the following stacktrace, shown below. What am I doing wrong? The docs seems…
greyfox
  • 6,426
  • 23
  • 68
  • 114
4
votes
1 answer

performing create-or-update with jdbi

For a small new project, I decided to give JDBI a try (normally I work with hibernate/jpa). I like the lightweight, annotation based dao creation using @SqlUpdate/@SqlQuery. But: There are situations where I can't be sure if I want to create an…
Jan Galinski
  • 11,768
  • 8
  • 54
  • 77
4
votes
2 answers

Configuring a Provider that returns a generic type in Guice

I'm trying to set up a Provider for DAOs created using JDBI. JDBI uses a Handle object (which is a wrapper around a JDBC Connection) and you can get hold of a DAO by using handle.attach(MyDaoType.class). Rather than having to write a separate…
Rob Fletcher
  • 8,317
  • 4
  • 31
  • 40
4
votes
3 answers

How do I create a Dynamic Sql Query at runtime using JDBI's Sql Object API?

I've been moving an existing project from jdbc to jdbi, and I've been making much use out of jdbi's beautiful SQL Object API. We're using mysql. While the SQL Object API can construct handled queries that are known at compile time, I couldn't find a…
Hans Z
  • 4,664
  • 2
  • 27
  • 50
3
votes
1 answer

Database throws Unable to Close Resource exception daily on first request

I get the following exception for the first request that comes to my server every day: org.skife.jdbi.v2.exceptions.UnableToCloseResourceException: Unable to close Connection. After the first request, any subsequent requests can access the database…
FSP
  • 4,677
  • 2
  • 19
  • 19
3
votes
1 answer

Dealing with DB instance IAM authentication token expiry

As per here after you generate an authentication token, it's valid for 15 minutes before it expires. Consequently, if you don't hold onto the connection it will expire after 15 mins. Upon application startup, we have code a bit like…
Hurricane
  • 1,454
  • 1
  • 13
  • 31
3
votes
0 answers

Eclipse is confused with Generics

I use JDBI in my project and I have a unit test like this: @Test public void testGetUser() { when(jdbi.withExtension(any(), any())).thenReturn(new ArrayList<>()); List users = dao.getUsers(); assertTrue(users.isEmpty()); } For…
LuizPoleto
  • 268
  • 1
  • 10
3
votes
1 answer

JDBI bind value or null in query?

JDBI query needs to support setting a value, or null, for multiple columns in the query. But, the following is inserting empty strings and zeroes, not nulls: handle .createUpdate("REPLACE INTO products(id, name, price) VALUES (:id, :name,…
Charney Kaye
  • 3,667
  • 6
  • 41
  • 54
3
votes
1 answer

Why are Queries in JDBI closeable?

I have a Java application which uses JDBI for my database code. I have many DAOs which use roughly the following construction for queries: return handle.createQuery(sql) .bind("variable", variable) .mapToBean(Bean.class) …
Peter
  • 1,032
  • 1
  • 11
  • 26
3
votes
0 answers

JDBI - How to map rowsets to java collections

I am using JDBI 1.3.9 and dropwizard, I would like to know how to call into a stored procedure that returns a row set of values and map it to a java collection. I have a stored procedure GET_EMP that returns rows of values as specified in the out…
serah
  • 2,057
  • 7
  • 36
  • 56
3
votes
0 answers

How to change BinderFactory Implementation in JDBI3 upgrade

Currently I am upgrading from JDBI2 to JDBI3 but it doesn't seem like there is an obvious translation for BinderFactory and it isn't mentioned in the upgrade docs. import org.skife.jdbi.v2.sqlobject.Binder; import…
Ryan Mavilia
  • 63
  • 1
  • 4
3
votes
1 answer

jdbi version 3, stringtemplate when to escape <, > characters?

I am using jdbi3 with StringTemplate 4 templating engine, I have this test query: @SqlQuery("select * from test " + "where field1 = 5" + " or field2 \\<= :value1" + " or field2 >=…
res1
  • 3,482
  • 5
  • 29
  • 50
3
votes
2 answers

sequence "testsequence" is not yet defined in this session in postgresql java

I am using java application with google juice as a injector along with jdbi as database layer.I need to fetch sequence from database using java code. I have tables in database for the application,which sequence are not used.But for other purpose I…
3
votes
1 answer

How to support CREATE TABLE IF NOT EXISTS for oracle database for jdbi?

We have a framework where we need to create a table if it doesn't exist. TABLE IF NOT EXISTS is not supported for Oracle. Any suggestion on how to implement it for Oracle database using jdbi?
user3634446
  • 133
  • 1
  • 10