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
1
vote
1answer
1k views

JavaSE client: is this how to get a new JPA EntityManager each time? (DAO)

This class functions, in that the program can be left open for hours and it will still reconnect to the database when the user prompts for a CRUD operation. I've read about DAO, and some other ...
2
votes
1answer
5k views

Multi-parameter search using JDBC PreparedStatement

I want to create multi parameter search using JDBC prepared statement so as to prevent SQL injection attack and improve performance. As I couldn't find the best way to do it on the net. I've tried ...
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 ...
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 ...
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 ...
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: ...
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 : ...
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 ...
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 (...
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 ...
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 ...
5
votes
2answers
172 views

Table model code style

This is my table model code style: ...
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 ...
1
vote
1answer
947 views

Generic DB Value Getter

I'm trying to see if there is a better way to do this when I just need one column with one row. Do not mind the lack of use of a prepared statement, I will put it in. ...
2
votes
1answer
575 views

Am I using appropriate methods in this login system?

I have had to do a crash course in JSP, Servlets, and JDBC. I decided to attempt a Login System. I'm unsure if my use of try/catch is appropriate and if I am closing database connections correctly. ...
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

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

How to optimize this SQL delete

I want to optimize the performance of this SQL query. If I populate this hashtable with one million keys the query will take around minute. How I can optimize this Java method for faster execution? <...
7
votes
3answers
35k 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 ...
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. ...
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 ...
7
votes
5answers
3k views

Accessing the only element of Java ResultSet

Does this code look OK? ...