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

learn more… | top users | synonyms

3
votes
0answers
38 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: guimusic/main this contains all all of ...
4
votes
2answers
46 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
2answers
155 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 ...
3
votes
1answer
427 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, ...
1
vote
1answer
240 views

Method to Return a Hibernate Session

Can this method be improved?: ...
3
votes
1answer
2k 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 ...
2
votes
3answers
613 views

Realizing a SQL ResultSet into a Map in Scala

I am trying to realize a java.sql.ResultSet into a map, in Scala. ...
1
vote
1answer
420 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
142 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
698 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
400 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
949 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
291 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
355 views

More efficient way to make a Twitter status in a string of just words

I am making an application where I will be fetching tweets and storing them in a database. I will have a column for the complete text of the tweet and another where only the words of the tweet will ...
4
votes
1answer
227 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
239 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 ...
11
votes
2answers
7k 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
102 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
531 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
153 views

Table model code style

This is my table model code style: ...
3
votes
2answers
153 views

How to design 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
601 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
449 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. ...
3
votes
2answers
2k 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
434 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 ...
2
votes
2answers
194 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
130 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
289 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? ...
5
votes
3answers
23k views

What is the most efficient way to convert a Java ResultSet to an Object[][]?

I have a module that builds swing tables based on an Object[][], then I have another module that queries a sqlite database and returns a ...
4
votes
1answer
412 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. ...
6
votes
3answers
3k 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? ...
6
votes
1answer
10k 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
5answers
1k views

Accessing the only element of Java ResultSet

Does this code look OK? ...