JDBC (Java DataBase Connectivity) is the base API which enables interacting with SQL database servers by executing SQL statements using the Java programming language.
4
votes
2answers
107 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 ...
-2
votes
1answer
82 views
Java REST WS function calling DB taking lot of time
I have a REST WS in Java using jersey that connects to 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 in ...
2
votes
1answer
51 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 ...
0
votes
0answers
48 views
Ingest data from an RDBMS to Hadoop Hive database using Sqoop
Context: The below code will run a series of steps in an ETL workflow. I would like the code to be reviewed to avoid memory bottlenecks and null pointer exceptions etc.
UseCase:
Ingest the data from ...
1
vote
1answer
39 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, ...
2
votes
2answers
104 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 ...
6
votes
1answer
46 views
1
vote
1answer
41 views
Speeding Up JavaMail Sending
I am creating a miniature bulk email sender. I am using Postfix on Ubuntu with JavaMail. Here is the key part of the code:
...
4
votes
2answers
50 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
81 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
2answers
58 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:
...
5
votes
2answers
153 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 ...
4
votes
2answers
457 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
818 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
316 views
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
2k 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
654 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
438 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
2k 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
796 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
2k 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
427 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
590 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
455 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
400 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 ...
14
votes
2answers
10k 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
111 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
869 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
156 views
3
votes
2answers
165 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
673 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
533 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
5k 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
619 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
200 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
148 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
323 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?
...
6
votes
3answers
31k 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
496 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
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
12k 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
2k views