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

ResultSet mapping to object dynamically in dropwizard

I was trying to map ResultSet data to an object and returning it. Here is how i'm mapping data to an object. Now i'm having only 7 columns in resultset so this is working fine but what if i'm having 20 or 30 columns. How can i map dynamically those…
Nike
  • 5
  • 6
0
votes
2 answers

How to select an aggregate query result into tuples using JDBI annotations?

I'm using JDBI and I need to run a query using aggregate functions. How would I go about reading the result from this query? What return type can I use to make it convenient? @SqlQuery("select count(*), location from Customers group by…
toniedzwiedz
  • 17,895
  • 9
  • 86
  • 131
0
votes
1 answer

dropwizard get on demand jdbi connection

I have a simple CRUD application with backend code in dropwizard. The entire app just comprises of simple resource classes and crud operations except one case where some business logic is involved. I am trying to extract this into a service instead…
Kaus2b
  • 747
  • 4
  • 12
0
votes
2 answers

Resolving multiple values returned from a query?

While this seems like a really simple problem, the only solution I've come up with is below, any suggestions for something less ugly with lower time complexity? My application is in Java and is retrieving with a MS-sql DB using skife.jdbi. Say I…
ab11
  • 19,770
  • 42
  • 120
  • 207
0
votes
1 answer

JDBI, Model Mapper and SQL Object Queries

I'm using Model Mapper with JDBI, but I'm not able to use model mapper with SQL Object Queries. For example I have this select @SqlQuery("select * from example") and documentation says I have to use a ResultSetMapper or ResultSetMapperFactory to…
Silvia
  • 11
  • 5
0
votes
1 answer

Java + MySQL + Inline User-Variables: Same query works in SQL editor, wrong outcome in JDBD (org.skife.jdbi)

I'm running a query like this: INSERT INTO `ABC` ( `col1`, `col2`) SELECT `t`.`col1`, `t`.`col2` FROM ( SELECT `opr`.`col1`, @counter := IF(@var_2 = `opr`.`col_2`, @counter + 1, 1) AS `counter`, @val_2 := `opr`.`col2` FROM (...Some…
Felipe Baytelman
  • 544
  • 3
  • 12
0
votes
1 answer

Generic class with parameters

public class ModelMapper implements ResultSetMapper { public Model map(int index, ResultSet resultSet, StatementContext ctx) throws SQLException { // Get result set meta data & column count ResultSetMetaData metaData =…
Viveran
  • 83
  • 1
  • 14
0
votes
0 answers

Optimal and memory safe way to retrieve millions of records out of mssql DB from Java?

I have a table with about 6 million records in it. I need to retrieve the ID of each row to process in Java. The ID is an alphanumeric nvarchar(8). I would like to do this a memory safe and efficient manner. Below is my approach, in it I: select the…
ab11
  • 19,770
  • 42
  • 120
  • 207
0
votes
1 answer

JDBI query when using type annotations?

I'm writing a Dropwizard app that needs to connect to the database, and using SQL objects to query the DB, per the Dropwizard docs. The issue I'm running into is when my query is using a type specifier (::) being confused for a binding variable.…
pablo.meier
  • 2,339
  • 4
  • 21
  • 29
0
votes
1 answer

what is the purpose of assertThat in JDBI?

I am going through a codebase that I found in github. I found a set of lines in the code that contains the following function:assertThat.Any help is appreciated. myObject = someDao.foo(obj); assertThat(myObject.getUpdated,isAfter(updated));
0
votes
1 answer

Dropwizard/Groovy - ERROR io.dropwizard.jersey.errors.LoggingExceptionMapper: ! groovy.lang.MissingMethodException

I'm trying to create a RESTful web API with Dropwizard. I believe that I have the database connected and running properly. However whenever I try to perform a GET request for a specific item I run into an error message: ERROR [2015-07-08…
Brandon Lee
  • 194
  • 2
  • 12
0
votes
1 answer

Restrict Dropwizard response object based on permissions

I am building a REST API with Dropwizard and JDBI and I need to work with different representations of the same resource. An example where we are working with a events resource: A event resource has properties field1, field2, field3 and…
Samuel Lindblom
  • 812
  • 1
  • 6
  • 22
0
votes
2 answers

Where should I store a DBI connection and when should I close it?

I'm storing it in a public static field public class DB { private static final String url = "jdbc:sqlite:file:target/todo"; public static final DBI dbi = new DBI(url); public static void migrate() { Flyway flyway = new…
Salah Eddine Taouririt
  • 24,925
  • 20
  • 60
  • 96
0
votes
1 answer

Update row in MYSQL database without knowing which columns at time of writing code?

I am using SQL objects API to work with the data in my database and have run into an annoying issue : When users are using my front end, they can type in values etc and pick from dropdowns etc before clicking apply to save all the changes to the…
Slippy
  • 1,253
  • 5
  • 22
  • 43
0
votes
1 answer

SQL Objects API - All rows?

I am having some trouble getting back all the rows in my table - Below you will see code for how I return one row (which works), and map it to a user object. controller code @GET @Timed @Path("/retrieve/{id}") public User…
Slippy
  • 1,253
  • 5
  • 22
  • 43
1 2 3
25
26