Questions tagged [jdbc]

JDBC (Java DataBase Connectivity) is the base API which enables interacting with SQL database servers by executing SQL statements using the Java programming language.

Filter by
Sorted by
Tagged with
0 votes
2 answers
120 views

Searchable database with Java and SQL

What does the code do? Albeit unfinished (it does work, it's just not complete yet), the code creates a database (members.db) where telephone numbers, IDs, and ...
user avatar
  • 119
0 votes
0 answers
33 views

Java database connection and DAO implementation feedback

First things first, I made a DatabaseConnection-class which connects to the database like so: ...
user avatar
  • 87
3 votes
1 answer
566 views

Testing DAO Delete User

I have several Dao classes, including a UserDao, below. The DAOs have many methods, but I'm focussing on deleteUser: ...
user avatar
0 votes
0 answers
44 views

Is my implementation of connection scope for Dao right?I have Dao and Service where I implement connection and transaction scope

I have DaoFactory that returns DaoImpl and can make connection/transation scope ...
user avatar
1 vote
1 answer
44 views

I have a query like this that seems complicated and I want to do it by using Java Stream Api

I have method that fetches sorted and filtered data from Mysql Database, Firstly I had done It by using Java. Now I did it by Mysql but I don't like the way the code looks I have entity that named ...
user avatar
5 votes
3 answers
2k views

Using static final Strings for SQL Query in Spring Boot

This is regarding code quality and coding standards with respect to Spring Ecosystem. Here there are two methods: isRecordExists is using a class level static ...
user avatar
4 votes
2 answers
82 views

MySQL JDBC integration into App from tutorial

I was following this tutorial for JavaFX and Gradle: JavaFX with Gradle, Eclipse and, Scene Builder on OpenJDK11 After completion of the tutorial you will have a simple GUI which you input a lower ...
user avatar
  • 165
4 votes
3 answers
2k views

Updating a huge hashmap from a resultset

I am using Java 7 Problem: I need to retrieve records from a database table based on a condition, orig_setting = 1. This query could return ~1000 records. Parameters from 1-7 of the Params object are ...
user avatar
  • 151
2 votes
0 answers
40 views

Library/API: simple springboot / jdbc query builder and ORM

I have been using and developing a simple ORM and query builder library that I have found useful in it's practical application. I am pretty sure there are improvements to be made, and I welcome any ...
user avatar
  • 121
5 votes
4 answers
244 views

Java methods to add and authenticate users in MySQL

I'm going through some code and trying to figure out how to get rid of duplicates from the following two methods. Both methods execute a simple login/register query to a local MySQL DB. I couldnt ...
user avatar
  • 61
2 votes
1 answer
324 views

Generating and storing a unique salt in Oracle database using Java

This is my account table: ...
user avatar
  • 143
0 votes
1 answer
77 views

Country, city, and address tables for a customer

I need to create a customer and I have foreign keys for each table. Below is an image displaying the relationships of the tables when I want to insert a new customer. Then below the diagram I list out ...
user avatar
2 votes
1 answer
47 views

PreparedStatement for closable recordset and connection

Following approach uses more Functional approach (non OOP), each method is passed DataSource as dependency. I've written this piece and I'm wondering if there's something that can be improved. I wish ...
user avatar
  • 205
1 vote
0 answers
240 views

Consumer Producer problem solution using JDBI, MySQL, HikariCP

The app suppose to solve a subset of Producer–consumer problem. One producer, one consumer thread and buffer. The idea of the app to handle correctly database downtimes. The solution is to keep ...
user avatar
  • 151
2 votes
3 answers
115 views

Business rule updater

I'm trying to increase the speed of my application at the moment. My inserting/updating methods were opening every time a new connection which took too much time. I read that it's better to create a ...
user avatar
  • 129
3 votes
1 answer
471 views

Static class for database access Java JDBC

I'm writing a small program to store data in a database (a discord bot mainly). I know cleaner ways of using dependency injections and DAO exist, but I haven't written a DAO (or the user class) and ...
user avatar
1 vote
1 answer
327 views

Simple JDBC Query By Example (QBE) for Spring JDBC Template

This is a quick and dirty QBE method that covers about 60% of my use cases in my DAO. I just wanted to see if someone would take a quick look at it to see if there are any issues. ...
user avatar
  • 385
-3 votes
1 answer
58 views

Is there a different way of implementing this program without using nested while loop? [closed]

Presently my program is working properly, but how do i implement this program without using nested while loop(one while loop within another while loop).This is a kids way of programming and my office ...
user avatar
1 vote
0 answers
67 views

JavaScript loop to copy JDBC query results to a 2D array

I have a JS running in Google App Script, but for me, it's like an overall example/problem I ran into more often. The script fetches via JDBC the results of a MySQL query. The result has about 60.000 ...
user avatar
  • 11
2 votes
2 answers
1k views

Slow SQL Server performance with multiple PreparedStatement loop

I have a need to update thousands of database records at a time. I am using a loop to generate the necessary PreparedStatement updates, but am hoping for a more ...
user avatar
  • 217
0 votes
1 answer
403 views

JDBC wrapper in a functional manner

I implemented a simple Java JDBC wrapper in Kotlin with Arrow functional library. ...
user avatar
1 vote
3 answers
3k views

Login module with JDBC

I made simple login module that is responsible for handling registration, and signing in my application. How can I improve this code? Are there any conventions for this case? The idea is to create ...
user avatar
  • 13
2 votes
2 answers
1k views

Jython using JDBC

I want to access databases by Jython by using JDBC drivers. I started with SQLite because this needs no database installation. I found two tutorials that implement similar things in Java and in ...
user avatar
  • 1,276
1 vote
0 answers
75 views

CRUD in JSP AND SQL

I would like to simplify my code when I add an entry. All is OK for 1 table (table = "ecole"). I can add an entry without problem. My problem is that I will wish to add a second table named "nom" in ...
user avatar
  • 61
2 votes
0 answers
313 views

Calling PL/SQL functions using JDBC in a Spring clone

I started to modify some old code and ended up creating a sort of spring jdbc framework. I know just the most popular design pattern, so I was wondering if my design was good. For example, to call ...
user avatar
2 votes
0 answers
411 views

Wrapper for sql.Connection

I wrote wrapper for Connection. It uses my Connection pool implementation. When the wrapper closes, the connection goes back to pool. ...
user avatar
  • 173
2 votes
2 answers
8k views

Transaction in spring boot

I am using spring boot in my application. ...
user avatar
  • 121
4 votes
0 answers
8k views

Simple MVC CRUD with JDBC

I would like to review my simple piece of code. I am beginner (I learn java for 1 year) and I would like to find out whether I am on good way. I have created simple MVC CRUD java app "ProductManager"....
user avatar
3 votes
1 answer
2k views

Online shop interacting with database, updating cart and instantiating products

I'm new to programming web sites (and so on the relationship between program and database) and I have encountered a problem. I'm creating an online web shop that interacts and saves every info on a ...
user avatar
1 vote
4 answers
97 views

Methods to get single and multiple JDBC results

I have two methods which are very similar apart from the method call inside and the return type. I wondered if there was a way to make it neater, i.e not duplicate the boiler plate connection code. I ...
user avatar
3 votes
3 answers
13k views

JDBC query with limit and offset

I have this method that lists database objects: ...
user avatar
  • 131
6 votes
1 answer
1k views

Java JDBC: MySQL database-wrapper

I'm currently enrolled in a further education with the topic database administration. Among other chapters it contains how databases can be accessed from application-software. Because it lacks ...
user avatar
  • 3,758
2 votes
1 answer
98 views

Java database query logic

I'm making a wrapper for querying the database so that I can more easily control the flow of database management and to make it easier for me to write data beans around my database. This code is ...
user avatar
  • 155
5 votes
2 answers
2k views

Authentication via LDAP and authorization via JDBC

I have a custom AuthenticationProvider for getting authentication via LDAP and authorization via JDBC. It's running but I think it's not the best way. My custom ...
user avatar
  • 151
3 votes
1 answer
106 views

Storing configurations of states to a database - Breadth First Search

I have wrote some code to store all possible configurations of a set of numbers in the sliding tile puzzle but the process of doing slow is very slow. Say, for instance, I have a sliding tile puzzle ...
user avatar
6 votes
4 answers
1k views

Simple Oracle connection using JDBC

I'm trying to continue the learning process in Java, and I've made a simple yet useful class which will allow me to retrieve the data inside a table from an Oracle DB, using JDBC. What I'm especially ...
user avatar
2 votes
1 answer
538 views

Using HikariCP and JDBC to store data for a Minecraft plugin

I'm creating a plugin for the game Minecraft, and with it I'm using HikariCP and MySQL to store data between server restarts. I've created working code but I'm wanting to improve it. While the code ...
user avatar
3 votes
1 answer
188 views

Classical model for database connection provider

Let's forget about Spring Singleton Beans and about other frameworks in Java. We have one or more simple HttpServlets. And we should make database connection. (doesn't matter what is it, hibernate ...
user avatar
0 votes
1 answer
681 views

JDBC helper model

I needed to create a basic JDBC helper class for our JDBC connection and wanted to know if my design is appropriate or needs cleans up? Just a basic JDBC utility class which helps reduce the ...
user avatar
  • 203
3 votes
1 answer
793 views

Get RSS feeds and store them into database

It is my first program in Clojure. It read RSS feed's list from text file, get each feed and store result into sqlite database. project.clj: ...
user avatar
  • 772
2 votes
1 answer
144 views

Java MySQL handler for a Minecraft mod

I am studying computer science and recently I developed an application in Java (it is a minecraft mod) that connects a MySQL database and queries to fetch, update or insert data. My DatabaseHandler ...
user avatar
  • 39
3 votes
1 answer
11k views

Reading SQL file using injection and utility reader

I've come up with a way to externalize and read in my .sql files instead of having them in-code as strings. Note that I'm keeping the .sql file in the same package as the DAO (NOT separated into a ...
user avatar
  • 131
1 vote
0 answers
2k views

Pagination from resultset for JTable

I am trying to create simple app, where I need a pagination for my JTable. I want have there buttons with number for all "pages" in my JTable. I have code here: Class Customer: ...
user avatar
2 votes
1 answer
4k views

JavaFX app which does CRUD on a database table

I created my first java application for a college assignment. I tried my best to design my application using best practices of MVC design patterns. I have read about it on Stack Overflow and other ...
user avatar
4 votes
2 answers
6k views

DAO to create, update, and delete a project

I'm trying to write my first "complex" program in Java. So far, I created a local H2 database but I'm not sure about the quality of my code (I'm newbie in Java) because I don't know how I can deal ...
user avatar
-2 votes
1 answer
101 views

REST WS connecting to a database

I have a REST WS in Java using Jersey that connects to a database. I don't know what should be the ideal time for execution but I feel the time it takes is too much. The actual call to DB completes ...
user avatar
2 votes
1 answer
1k views

Connection pool for java.sql.Connection

I have made a connection pool for SQL Connection objects. The purpose of this object is to provide multi threaded support for the accessing of the underlying ...
user avatar
  • 1,347
1 vote
1 answer
119 views

Recording a customer's shopping cart as an order 2.0

Some days ago, I put up a question here for review about the best way to handle JDBC transactions in the context of an e-commerce Java web application. After a kind suggestion from user @gardenhead, ...
user avatar
  • 155
2 votes
2 answers
259 views

Recording a customer's shopping cart as an order

I have come up with the following method to post a transaction to a database, in the context of an e-commerce Java web application. The transaction consists in submitting a new order alongside its ...
user avatar
  • 155
6 votes
1 answer
67 views

Library of news articles

I have a library of news articles. Each story is unique by id. ...
user avatar
  • 215