JDBC (Java DataBase Connectivity) is the base API which enables interacting with SQL database servers by executing SQL statements using the Java programming language.
1
vote
1answer
49 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
1answer
70 views
Method to close a lot of closeable objects
I wrote a method that closes 3 closeable types:
java.sql.Connection
java.sql.PreparedStatement
...
5
votes
2answers
72 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
...
3
votes
1answer
80 views
Converting JDBC to CSV
One of my first ever jython scripts lets me get comma-separated values out of an RDBMS. I submit it here in hopes that you'll rip me apart. Without further ado, have at it:
...
4
votes
1answer
88 views
More efficient way to make a Tweeter 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
92 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
93 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 ...
8
votes
2answers
1k 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
76 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
163 views
Getting list from 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? I have the below code as of now. ...
5
votes
2answers
132 views
3
votes
2answers
103 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 ...
2
votes
1answer
225 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
1answer
221 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 ...
1
vote
2answers
245 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
10k 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
286 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
2k 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?
...
4
votes
1answer
7k views
Is there a better way to paginate large SQL-Results?
It feels like pagination is one of the most discussed questions on the web, which always ends up with some quick&dirty hacks on how to paginate. I want to paginate a large result set from an SQL ...
6
votes
5answers
1k views