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
26
votes
3answers
26k views

Connection pool implementation

I wanted to try out writing an minimalistic connection pool implementation (out of curiosity and for learning). Could you all please review the code and provide feedback? There are two classes (...
7
votes
5answers
3k views

Accessing the only element of Java ResultSet

Does this code look OK? ...
7
votes
3answers
34k views

Module for building swing tables

I have a module that builds swing tables based on an Object[][], then I have another module that queries an SQLite database and returns a ...
7
votes
3answers
4k views

Connection pool in Java

Please review this connection pool. I tested it and it works but can we improve it from design or performance perspective? ...
7
votes
1answer
18k views

Paginating large SQL-Results

It feels like pagination is one of the most discussed questions on the web, which always ends up with some quick and dirty hacks on how to paginate. I want to paginate a large result set from an SQL ...
6
votes
4answers
642 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 ...
6
votes
2answers
7k views

Inserting tables with foreign key

How can I improve this method that adds data to three tables in the database? The tables are: UserTable UserInfoTable ...
6
votes
1answer
63 views

Library of news articles

I have a library of news articles. Each story is unique by id. ...
5
votes
1answer
2k views

Connection to a database, do I need to create a new one and close it everytime?

I currenctly have a class which does several requests to a database with several methods (called from main method) sharing this pattern : ...
5
votes
2answers
172 views

Table model code style

This is my table model code style: ...
5
votes
2answers
1k views

Serialize/deserialize objects to and from database concurrently

I have a class which runs as spring bean in the container and its purpose is data persistence. In the overriden method ...
5
votes
2answers
1k 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 ...
4
votes
2answers
113 views

SQLite UPDATEs for persons and a subclass

I am using Java with SQLite and I am wondering if I am in the right track onto writing good code i.e. more or less reusable: SQL scheme: ...
4
votes
1answer
1k views

Finding potential thread safety issues and race conditions in my multithreading code

I am working on a project in which I have two tables in a different database with different schemas. So that means I have two different connection parameters for those two tables to connect using JDBC-...
4
votes
2answers
4k 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 ...
4
votes
2answers
19k views

Student Registration System

This application is a "Student Registration System" using JDBC with Oracle as part of our school project. It works as it stands right now. Questions: What is a better way to structure the project? ...
4
votes
1answer
1k views

Execute multiple query from a text file

I am just wondering if this is a correct way to execute multiple query from a text file. ...
4
votes
2answers
4k views

Creating and deleting employees in a database

I've been learning Java Database Programming for like 2 days, I read theory at first. Now decided to get stuck in. I just wanted a few pointers. I am using JavaDB (Netbeans Service) should I be ...
4
votes
1answer
867 views

Converting JDBC to CSV

One of my first ever Jython scripts lets me get comma-separated values out of an RDBMS: ...
4
votes
1answer
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 ...
4
votes
2answers
96 views

JDBC connection and retrieval of info

If you are wondering why I ask, it is because I have numerous different methods all with very similar code (the only difference in the code in each method is what is between the generate ...
4
votes
1answer
132 views

GUI SQL interface for select insert and remove

This is my final project for my second Java class! I would like to get some feedback on it to see where and what I can improve. There are five class files: ...
4
votes
1answer
3k views

Loading the JDBC driver jar dynamically from external location

I have a small project in which I get the URL, username, password, and driver from a text file and I have to fire a query on the database by dynamically reading the jar file in a predefined directory, ...
4
votes
0answers
5k 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"....
3
votes
3answers
368 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 ...
3
votes
3answers
7k views

Realizing a SQL ResultSet into a Map in Scala

I am trying to realize a java.sql.ResultSet into a map, in Scala. ...
3
votes
3answers
4k views

Method to close a lot of closeable objects

I wrote a method that closes 3 closeable types: java.sql.Connection java.sql.PreparedStatement ...
3
votes
1answer
94 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 ...
3
votes
1answer
611 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: ...
3
votes
1answer
4k views

MySQL Java in JTable

This is an assignment posted here. (Part-B) The aim here is to create a GUI in which the user can search for and insert data into a particular table of a MySQL database. Is this an appropriate ...
3
votes
1answer
757 views

Design considerations for classes/methods using JDBC to ensure resources closed correctly

In reviewing code in our application, I see a tension between what makes a convenient design for methods accessing database data versus coding to ensure that the JDBC resource objects are closed ...
3
votes
2answers
202 views

Inserting into database columns

I am trying to insert into a database using JDBC and each thread will be inserting into the database. I need to insert into around 30-35 columns. I wrote a stored procedure that will UPSERT into those ...
3
votes
1answer
3k views

Getting list from an Oracle database and storing it in an object

I have two admin groups - VCS, and VPN. For each group, I need to get the list of all the people in that group, along with their IDs. What is the best way to do this? Could you please suggest if it ...
3
votes
2answers
237 views

Designing DAOs that handle composite objects

Suppose I have following elementary DTOs, each DTO corresponding to a database table: class Event { String name } class Player { String name } DAOs for ...
3
votes
1answer
46 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 ...
3
votes
1answer
985 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 ...
2
votes
2answers
8k views

Transaction in spring boot

I am using spring boot in my application. ...
2
votes
2answers
252 views

Inserting into a database using JDBC

I am trying to insert into a database using JDBC and each thread will be inserting into the database. I need to insert around 30-35 columns. I wrote a stored procedure that will UPSERT into those ...
2
votes
3answers
6k views

JDBC query with limit and offset

I have this method that lists database objects: ...
2
votes
1answer
60 views

Generating and storing a unique salt in Oracle database using Java

This is my account table: ...
2
votes
1answer
93 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 ...
2
votes
1answer
8k views

Basic CRUD DAO using JDBC to access my database

I have a basic CRUD DAO using JDBC to access my database. I using a connection pool to get a connection in each method and then execute my commands. In some scenarios for update ...
2
votes
2answers
595 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 ...
2
votes
1answer
255 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 ...
2
votes
1answer
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 ...
2
votes
2answers
244 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 ...
2
votes
1answer
143 views

How to hide implementation of JDBC while processing large query in client's code?

I have client's methods that processes a large SQL query. I wouldn't like to do that through getting whole query result to memory, but process it in batches. It entails with exposing JDBC API to ...
2
votes
1answer
135 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 ...
2
votes
1answer
111 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 ...
2
votes
1answer
7k 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 ...