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
10
votes
2 answers

How do you inject jdbiFactory DAOs into a Dropwizard Command?

I'm starting to work with Dropwizard and I'm trying to create a Command that requires to use the database. If someone is wondering why I'd want to do that, I can provide good reasons, but this is not the point of my question anyway. It's about…
ggalmazor
  • 710
  • 6
  • 18
9
votes
3 answers

Dropwizard and Guice: injecting Environment

I am currently building a Dropwizard + Guice + Jersey-based application where the database access is being handled by JDBI for the time being. What I am trying to achieve is to have your typical enterprise architecture, where Resources access…
CptPicard
  • 196
  • 1
  • 5
  • 17
9
votes
1 answer

JDBI, retrieve data with sql query into customized object(constructor) instead of Map

So when we use JDBI to query from database, it is getting it into a Map type. I want to get it as my customized object (constructor) instead of Map. DBI dbi = establishConnection(url, userName, passWord); Handle…
ringord
  • 908
  • 3
  • 11
  • 27
9
votes
1 answer

Does JDBI accept UUID parameters?

When using SQL Object argument binding, does JDBI work out-of-the-box with UUID parameters? I have a method such as this: @SqlQuery("EXECUTE [MyProcedure] :myField") MyDto myMethod(@Bind("myField") UUID myField); which is bound to a SQL Server…
Fernando Correia
  • 21,803
  • 13
  • 83
  • 116
8
votes
1 answer

JDBI3 dynamically create a WHERE clause

How I can create dynamic where public interface ThingDAO { @SqlQuery("SELECT * FROM things ) List findThingsWhere(@Define("where") String where); } JDBI How can I dynamically create a WHERE clause while preventing SQL…
LeshaRB
  • 1,345
  • 2
  • 23
  • 44
8
votes
2 answers

JDBI How can I dynamically create a WHERE clause while preventing SQL Injection?

I want to dynamically filter a JDBI query. The a list of parameters is passed from the UI via REST e.g. http://localhost/things?foo=bar&baz=taz http://localhost/things?foo=buz Which is (clumsily) built (Jersey @Context UriInfo::getQueryParameters…
unSinn
  • 301
  • 3
  • 8
7
votes
1 answer

Spring Boot Custom Bean Loader

I am using JDBI in tandem with Spring Boot. I followed this guide which results in having to create a class: JdbiConfig in which, for every dao wanted in the application context, you must add: @Bean public SomeDao someDao(Jdbi jdbi) { return…
JDrost1818
  • 1,116
  • 1
  • 6
  • 23
7
votes
2 answers

JDBI - What's the difference between @define and @bind in JDBI?

Are both functions sanitized / safe against SQL injection? For example, consider the following: @SqlUpdate("INSERT INTO () VALUES ()") public abstract void addRowToDataset(@Define("tableName") String tableName,…
lingz
  • 321
  • 3
  • 14
7
votes
2 answers

JDBI's @BindBean doesn't find named parameters in bean class during INSERT

I am consistently getting the following exception below when inserting values using JDBI's @BindBean into my Mysql database within Dropwizard. The problem seems to be that JDBI is unable to find the properties in the bean. I already isolated the…
keyboardsamurai
  • 703
  • 1
  • 9
  • 20
6
votes
2 answers

Mapping @Json property with JDBI

According to JDBI document https://jdbi.org/#_jackson_2, it seems that it's quite straight forward to have a json property of your object model, however I've tried the following and it ran into many issues. DB: Postgres with a column type of…
Tin Ng
  • 937
  • 2
  • 11
  • 25
6
votes
2 answers

Query timeout for JDBI

1) Is it possible to set up global value of queryTimout for Dropwizard's JDBI mysql connector? What is the default value? I dont want to use @QueryTimeOut in every single DAO. 2) And what about java.​sql.​Statement.Connection where is networkTimeout…
YasiuMaster
  • 299
  • 2
  • 5
  • 15
6
votes
1 answer

Using JDBI @BindBean with AutoValue

TLDR; The JDBI @BindBean annotation generates an IllegalAccessException with AutoValue generated types because the generated types are package private and by default can't be accessed by default using reflection. Is JDBI inflexible or is there a…
vpiTriumph
  • 3,116
  • 2
  • 27
  • 39
6
votes
1 answer

Can JDBI DAO instance be reused?

final MyDAO dao = database.onDemand(MyDAO.class); Can dao instances be reused? Or do we need to instantiate it for every use? From code it looks like it is responsible for maintaining a DB transaction. However, in DropWizard the examples is:- final…
AppleGrew
  • 9,302
  • 24
  • 80
  • 124
6
votes
2 answers

Optional jDBI parameter

Is it possible to have optional (null) parameters with jDBI queries? I'm attempting to get optional parameters working in a database query. I am working with dropwizard. @SqlQuery("SELECT * \n" + "FROM posts \n" + "WHERE…
nckturner
  • 1,266
  • 1
  • 15
  • 19
6
votes
1 answer

How do we force Resource(controller) level transaction in Dropwizard with jdbi?

In spring, we have @Transactional annotation which can be specified at Controller, so everything happens inside a controller method is treated as one transaction. However in dropwizard, we can have transaction at a DAO level by implementing…
xxxxx
  • 1,918
  • 2
  • 17
  • 22
1
2
3
25 26