Click here to Skip to main content
15,890,438 members
Everything / JDBC

JDBC

JDBC

Great Reads

by Bert O Neill
Query Hadoop using Microsoft oriented technologies (C#, SSIS, SQL Server, Excel etc.)
by Bogdan Marian
Ensure your Docker Compose services start in the correct order
by anshulskywalker
Understanding of Example Based Machine Translation (EBMT) system and how to create your own using exisiting tools
by V.
How to dynamically build a JQPlot graph through the code behind.

Latest Articles

by Bogdan Marian
Ensure your Docker Compose services start in the correct order
by Łukasz Bownik
A fluent JDBC wrapper written in 200 lines of code
by James A. Brannan
In this tutorial, we secure a simple Rest API. We begin with a simple example, progress to using a custom UserDetailsService, and finish by adding method level security.
by Han Bo Sun
In this tutorial, I will introduce the use of Spring JdbcTemplate in a Spring Boot web application. This tutorial will show how to create the necessary configuration for JdbcTemplate. And how it can be used for data insertion and retrieval.

All Articles

Sort by Updated

JDBC 

27 Oct 2023 by Kanchana Gallage
I am doing implementation for this type of SELECT query in a Spring boot application using named parameter jdbc template. Database used is postgres. SELECT lp.*, gp.NAME, gp.description, FROM global_products gp...
27 Oct 2023 by Richard Deeming
Quote: Adding ORDER BY clause gives the similar order and data every time but I do not need that for the requirement. Except you do need that. If you don't specify an explicit order for the results, then the order is undefined. The DBMS is...
20 Mar 2023 by Bogdan Marian
Ensure your Docker Compose services start in the correct order
21 Nov 2022 by Marc Brolly
Each time I click on the JCombobox's arrow to show the list of exercises, it will continue to populate the combo box with duplicates entries shown in the image, made code is also inserted. I know its to know with the re-clicking of the arrow due...
21 Nov 2022 by Marc Brolly
Question was resolved by adding exerciseList.removeAllItems(); before the for loop public void popupMenuWillBecomeVisible(PopupMenuEvent e) { ArrayList nameList = new ArrayList(getComboValues()); ...
17 Nov 2022 by Marc Brolly
I'm trying to get the primary auto incremented key from one table and store this in another using MySQL connector and JDBC. Although its giving me this error - 'statement.executeupdate() cannot issue statements that produce result sets.' I...
17 Nov 2022 by Richard Deeming
Quote: insertQueryGetId("SELECT workoutID FROM workout") ... workoutID = statement.executeUpdate(query, Statement.RETURN_GENERATED_KEYS); You're passing a SELECT query to the executeUpdate method. The error clearly tells you that this is not...
13 Nov 2022 by Member 15489491
I am passing a Set in my query but the data is being passed like this : ('[john,ray,mike]') but I want to pass the data like this in the query: ('john','ray','mike') How Can I do that? What I have tried: This is what I have tried: ...
21 Oct 2022 by Joydeep Banerjee 2022
Create a database for a Student Result system consisting of the following two tables: Student (SID, name, ContactAddress) Results (SubjectID, SID, Marks) Develop and deploy a web based “Result Display System” using JSP, any database backend and...
21 Oct 2022 by Richard MacCutchan
Sorry, this site does not provide code to order. If you are unable even to start your assignment then you should review your course notes and/or talk to your teacher.
15 Jul 2022 by Amey D
Below are my connection settings for Oracle SQL Developer with tnsnames.ora Imgur: The magic of the Internet[^] The pattern of jdbc string required is as below : jdbc:oracle:thin@:1521: What I have tried: I have tried the...
10 Jan 2022 by Member 15493982
I have a selected row statement but it always return the first row. I have a statement fireTableDataChanged() when I delete or add a row and I don't now cause is that or not. My code here Selected row statement: public void...
10 Jan 2022 by Richard MacCutchan
Most likely because you are using the wrong event. See AbstractTableModel (Java Platform SE 7 )[^]. which lists the different events that are generated when adding or deleting rows.
10 Jan 2022 by OriginalGriff
This is the second time you have posted this exact question, and nothing has changed in the meantime. So what is the point of posting the same thing? All you are staying here is "It don't work", and "I've done nothing to fix it myself". That's...
21 Nov 2021 by Alex Darius
statement3.execute("CREATE TABLE accomodation_fare_relations (\n" + " id integer,\n" + " id_accomodation integer NOT NULL,\n" + " id_room_fare integer NOT NULL,\n" + " PRIMARY...
21 Nov 2021 by OriginalGriff
Start by checking that the table create statement is executed, throws no errors, and that the table actually exists afterwards - use SSMS to check that last bit, and the debugger for the other two. If the table exists afterwards, use the...
24 Sep 2021 by Richard MacCutchan
The only way to make any progress is learn the technology, and practice, practice, practice. A good place to start is Java Tutorials Learning Paths[^].
14 Jul 2021 by getrelax
I want to connect and access to HSQL DB from C#. I am trying to use JNI to invoke Java code in C# environment. The challenge is how to write java import statement in C# environment. What I have tried: I used the reference shown in this link...
28 Jan 2021 by RickZeeland
Check if your firewall does not block the port. Also see: Java JDBC - How to connect to Oracle using Service Name instead of SID - Stack Overflow[^]
27 Jan 2021 by Richard MacCutchan
Check that you connection string parameters are valid: Features Specific to JDBC Thin[^].
9 Apr 2020 by Wendelius
One reason for not returning any data could be if the column is case sensitive. You can try the following SELECT pxp.invoice, p2.bookingRef FROM pxp, PolarCruiseBrandPaxFile2 p2 WHERE pxp.invoice COLLATE UTF8_GENERAL_CI LIKE '%' +...
9 Apr 2020 by Member 12858897
Can someone help in resolving one of following commented lines please? I tried with LIKE as well as CONTAINS. Got no result with like but the values are there. Also, CONTAINS doesn't seem to work in mySQL LIte. CREATE TABLE...
19 Feb 2020 by Łukasz Bownik
A fluent JDBC wrapper written in 200 lines of code
29 Jun 2019 by shreeram09
I have created spring mvc project in which I am using JdbcTemplate mechanism to carryout database operations. I am running a scheduler which 1. parses XML file with 300K records 2. validates each field and stores in a model object 3. after preparing object, search in database with select query...
20 Apr 2019 by dhruv1707
Hello i have big data in my oracle 10g database and have to perform some calculations on every row of resultset. So i call a separate calculation class after fetching value of single row in the while(rs.next) loop. But this actually gives me multiple java.sql.SQLException: Closed Connection...
25 Mar 2019 by James A. Brannan
In this tutorial, we secure a simple Rest API. We begin with a simple example, progress to using a custom UserDetailsService, and finish by adding method level security.
3 Dec 2018 by Han Bo Sun
In this tutorial, I will introduce the use of Spring JdbcTemplate in a Spring Boot web application. This tutorial will show how to create the necessary configuration for JdbcTemplate. And how it can be used for data insertion and retrieval.
19 Aug 2018 by Richard MacCutchan
See Getting Started · Accessing Relational Data using JDBC with Spring[^].
19 Aug 2018 by Member 13954180
Hi, I would like to know what version of JDBC I should use Oracle DB 12.1 and Java 8. I've read that there is: JDBC 4.1 in ojdbc7.jar That would be fine of cause. But what should I use for DB access with Spring to access the DB? What is for the different Spring Projects the right version...
2 Jun 2018 by OriginalGriff
The obvious answer is: the userid and password do not match, so nothing is returned. Use the debugger, to single step through your code and check exactly what is happening, and what is in the various variables. But please, don't do that: Never store passwords in clear text - it is a major...
2 Jun 2018 by Member 13856100
hi. i want to create login page that only user who had role as admin can login. here is my databases : tb_users : user_id (PK, string) password tb_user_auth : user_id (FK,string) objects_id // contain user's role(string) the problem is it seems like i retrieve nothing from objects_id so...
11 May 2018 by ThilinaMD
try this (assuming you have default port number for mysql). Class.forName("com.mysql.jdbc.Driver"); Connection con = DriverManager.getConnection ("jdbc:mysql://localhost:3306/dblabor","root","root"); System.out.println("Connection successful");
11 May 2018 by Member 13814158
Hi guys, I get this error when I want to connect to my database. Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. I use MySQL Workbench Eclipse and Apache. My code is ...
9 Apr 2018 by It is what it is
(1)first thing I would do is go into sql server config manager and enable the browser service (2)then open windows firewall and create new rule to allow UDP traffic through port 1434 see this article for more info: ...
8 Feb 2018 by Jochen Arndt
You already found one. Another one is Stack Overflow - Where Developers Learn, Share, & Build Careers[^]. There are also many sites for specific programming languages and frame works. So you might want to search for such instead by adding a specific language to your search query. If you are...
8 Feb 2018 by Mehdi Gholam
Your question is too vague, hence the general answer of using Google. You can also try : Stack Overflow - Where Developers Learn, Share, & Build Careers[^]
7 Feb 2018 by four systems
code for database records are added when the program runs, required however is the code which reads from text file and adds records on database package Rdbms; import java.sql.*; import java.io.*; class javardbms { public static void main(String args[])throws Exception{ ...
7 Feb 2018 by shwetakakran
import java.io.File; import java.io.FileInputStream; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; public class InsertTextFileToOracle { public static Connection getConnection() throws Exception { String driver =...
1 Feb 2018 by four systems
Code for values that are taken from user and inserted into database but gives error "java.sql.SQLException: The column position '45' is out of range. The number of columns for this ResultSet is '2'." when user enters 45 as number, the code takes that as column number which is 2 what must be...
1 Feb 2018 by four systems
Code for bulk insertion of values from file to database the error is "Syntax error: Encountered "load" at line 1, column 1. package Rdbms; import java.sql.DriverManager; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; import...
31 Jan 2018 by Richard MacCutchan
You are using the input number, instead of the column index in your SetString statement. It should be something like: myStmt.setInt(1 , a); // column 1 is the ID value myStmt.setString(2 , firstName); // column 2 is the string name See PreparedStatement.setString[^]
29 Jan 2018 by four systems
code for jdbc is , on run the error is java.sql.SQLSyntaxErrorException: Column 'ID' is either not in any table in the FROM list or appears within a join specification and is outside the scope of the join specification or appears in a HAVING clause and is not in the GROUP BY list. If this is a...
29 Jan 2018 by Jochen Arndt
I don't know if this is the reason of the error but string parameters should be enclosed by quotes: stmt.execute("INSERT INTO " + tableName + " VALUES (" + id + ", '" + Name + "')"); Such problems can be avoided when using parameterised queries as already suggested. Another possible reason for...
29 Jan 2018 by shwetakakran
For connecting java application with the mysql database, you need to follow 5 steps to perform database connectivity. In this example we are using MySql as the database. So we need to know following informations for the mysql database: Driver class: The driver class for the mysql database is...
29 Jan 2018 by Richard MacCutchan
java.sql.SQLSyntaxErrorExcepti...
1 Jan 2018 by daulmalikm
i want to work on a project based on image encryption application where i wish to use chaotic image encryption algorithm. does it will supprt all types of image formats? What I have tried: Basic guide and tutorial about encryption technique.
1 Jan 2018 by RDBurmon
yes it does, but it depends on which image library you use in Java, first of all lets learn about this algoritham Proposed an effective chaotic encryption scheme based on confusion and diffusion principles. • Introduced bitwise circular rotation operation to increase plaintext sensitivity. ...
30 Dec 2017 by Rain Alex
I have a problem and I'm not to sure about how to go about handling it. I have a group a students in a school management database that I need to randomly assign to pre-defined groups. I've done a lot of research on group assignment but I can't quite find what I'm looking for. Basically, a...
7 Aug 2017 by H.AL
I have created my first API using java httpServlet on netbeans. After days working I could finally connect it to this mySQL googleCloud database and get results locally. But once this API is published on google cloud using appengine, below error was thrown: Error...
6 Jul 2017 by Bilal Zafar
Hello all, I am very new to java, so please ignore if you think this question is stupid. A task has been assigned to me in which I have to extract data from h2 database table with **more than 1 crore rows (SAD) from one table.** And finally show that data into a j table with pagination. What i...
6 Jul 2017 by KarstenK
Open a database and fetch data is expensive, so normally is a bunch of data fetched, stored in the data model and than displayed. I would fetch data set for at least two pages depending on the speed. A somehow similar example by fetching all data and storing it into the plain model array ("data").
8 Mar 2017 by Member 13047430
create or replace procedure updateStudentResult(id int,m1 in int,m2 in int,m3 in int,tot out int,avg out float,grade out char)asbeginselect marks1,marks2,marks3 into m1,m2,m3 from students where...
8 Mar 2017 by RAMASWAMY EKAMBARAM
(1)Modify last param in procedure declaration to avoid ambiguity:create or replace procedure updateStudentResult(id int,m1 in int,m2 in int,m3 in int,tot out int,avg out float,grd out char) -- grade renamed as grdand replace every occurrence of 'grade := ' to 'grd :=...
2 Dec 2016 by Member 12882201
I am using windows 10 64 and has ms access 2016 and jdk 8. How do I connect my java code with database of ms accessWhat I have tried:I tried using jdbc odbc driver, but I came to know that it is no longer used and removed from jdk.
2 Dec 2016 by ridoy
You can go with UCanAccess[^]Detail solution: eclipse - Manipulating an Access database from Java without ODBC - Stack Overflow[^]
1 Dec 2016 by Richard MacCutchan
See jdbc msaccess - Google Search[^].
14 Oct 2016 by Water1988
My project need to access some .dbf file. But I'd like use jre1.8, so I can't use odbc-bridge. I find some kind of jdbc. But they are not free, or can't display Chinese. What can I do?What I have tried:I used "htxx", but I can only use it 30 days. I find tinysql, but I can't display...
14 Oct 2016 by Mehdi Gholam
Be friends with Google: GitHub - iryndin/jdbf: Java utility to read/write DBF files[^]JavaDBF Tutorial[^]GitHub - jamel/dbf: Java library for fast reading DBF-files.[^]...
13 Oct 2016 by Member 12756458
package sql;import java.sql.Connection;import java.sql.DriverManager;import java.sql.PreparedStatement;import java.sql.ResultSet;import java.sql.SQLException;public class ConnectionDemo { public static void main(String[] args) { try...
13 Oct 2016 by Member 12793180
According 2 my point of view, u should write ps.executeUpdate() after ps initialziation
26 Sep 2016 by Member 9590560
I would personally use st.executeUpdate() which returns an integer. If the integer value is greater than 0, the statement has been executed successfully otherwise it will either be 0 or throw an error which will be caught in the catch block.Another issue would be in database connection. Have...
23 Sep 2016 by Robert Crystler
Hi Friends,I am trying to connect to my sqlserver database using JDBC code. I have some problem with the syntax. I have SQLServer database in my local system. I wrote the syntax,connection = DriverManager.getConnection("jdbc:microsoft:sqlserver://lm1189//:What_I_Pay");// lm1189 is...
23 Sep 2016 by Member 12756458
JDBC is simply a bridge which fills the gap of connectivity between the java Program and databases.
27 Jun 2016 by Stack Holder
Solved: Connection conn = DriverManager.getConnection("jdbc:sqlserver://localhost\\MALIKUSMANNAWAZ:1433;databaseName=ali","sa","dbase"); System.out.println("connection created"); Statement st=conn.createStatement(); String sql="select * from Login_System";
27 Jun 2016 by Stack Holder
import java.sql.*;public class Conection{ public static void main(String a[]) throws ClassNotFoundException, SQLException { try { String url = "jdbc:sqlserver://localhost\\MALIKUSMANNAWAZ:1433;databaseName=ali"; ...
19 Jun 2016 by Stack Holder
I am using windows authenication in sql server 2012.I want to connect java to sql.I have following code (just for example AND Some code is missing as copied from netbeans you know) public class app extends javax.swing.JFrame { public app() { ...
6 Jun 2016 by Member 12569519
how to retrieve data from database and display it in table with edit,delete option? using (jdbc servlet html css)What I have tried:using jdbc and servlet I can fetch the data but unable to form it in table and add edit,delete option.
6 Jun 2016 by George Jonsson
You could try to use AngularJS. Here is one starting point out of many:AngularJS Tutorial[^]And this one Angular JavaScript Framework: Interacting with Java Servlet Backend[^]
14 May 2016 by Member 12524018
I am calculating the price of a ticket with discount on weekdays and weekends based on the time duration.So, i gave inputs of duration and date using datepicker plugin which is in Above Page. For this i am getting proper result.But i have to create two different jsp pages(date.jsp and cal.jsp)....
14 May 2016 by Sergey Alexandrovich Kryukov
Probably you can received detailed answers based on session and specific to JSP.I want to suggest more universal and modern alternative based on Web storage. This approach is agnostic to the server side; it can even work without any server side at all, when you simply want to restore some UI...
26 Apr 2016 by Member 12486155
I am having problems inserting data into a postgres table created using java. The created table part of the code works fine, its only when I am inserting values into the table that nothing happens. The code I am using to populate the table tt is:What I have tried:private void...
26 Apr 2016 by Member 12486155
resolved just i have to add c.commit() after pst.executeUpdate();
24 Apr 2016 by Raj Negi
I am new to SOAPUI. On internet i found, this can be done with two ways: Either i can use SoapUI JDBC wizard or Using groovy script. First i tried to create connection using Wizard but i am getting this error :com.eviware.soapui.support.SoapUIException: Failed to init connection for driver...
29 Mar 2016 by Giancarlo Rhodes
ORM objects and basic CRUD operation procedures are first phase tasks that come after establishing a first version of the database. This java-based code generation tool builds those classes and stored procedures.
9 Mar 2016 by Member 11408361
Im having difficulty connecting my sqlite database to my netbeans application. Once i run the code below i get the error /Users/lm/Library/Caches/NetBeans/8.1/executor-snippets/run.xml:48: Cancelled by user. BUILD FAILED (total time: 1 second)I have also imported the jar...
7 Feb 2016 by Richard MacCutchan
You have an error in your statement for the Values clause: see PHP Insert Data Into MySQL[^] for correct syntax. Also you should not use string concatenation for SQL statements: see bobby-tables.com: A guide to preventing SQL injection[^].
7 Feb 2016 by Member 12146841
Hello! Im trying to write some method, which will add a new record to date base.Code:public void insertToPlayList() { try { connecting(); stat6 = Connection.createStatement(); stat6.executeUpdate("INSERT INTO odtwarzane...
23 Jan 2016 by Roland 57
theQuery("delete from authors where id = '"+authorIDLabel.getText()+"'");
22 Jan 2016 by Member 12278958
private void btndeleteActionPerformed(java.awt.event.ActionEvent evt) { try{ theQuery("delete from authors where id = "+authorIDLabel.getText()); } catch...
29 Dec 2015 by Bert O Neill
Query Hadoop using Microsoft oriented technologies (C#, SSIS, SQL Server, Excel etc.)
8 Sep 2015 by suman sgs
Hi,I have created a Dynamic web application in java,jsp and connected to MySQL server using phpMyAdmin as localhost database server.The code for connection class:static final String JDBC_DRIVER = "com.mysql.jdbc.Driver"; static final String DB_URL =...
9 Jul 2015 by datta789
in jsp why we use arraylist to store simple javabean(not EJB) and what happens without using arraylist to use javabean in jsp during jdbc connectivity. in many source codes i have seen that javabean is stored in arraylist and then accessed in jsp.why we need to store data of database in...
9 Jul 2015 by Patrice T
You need to split you question in 5 simple more general problems:- query your oracle database and get result.- convert Oracle date to JS date- Do calculation on dates with JS- convert JS date to a string with the format you want- display result in your html page (send some...
8 Jul 2015 by datta789
I want to display date calculation from oracle database on html form using jsp.I have expiry date and current date columns with date datatype in return table and want to show fine if current date is greater than expiry date using total days * 2 with date format 08-jul-15(dd-mon-yy) on html...
5 May 2015 by Jitendra_Jain04
IBM WebSphere Application Server V8.5 Liberty profile is a flexible and dynamic server profile of WAS which enables the WAS server to deploy only required custom features instead of deploying a big set of available JEE components.
13 Apr 2015 by RajeeshMenoth
Hi, The JDBC Driver interface provides vendor-specific implementations of the abstract classes provided by the JDBC API. Each vendors driver must provide implementations of the java.sql.Connection,Statement,PreparedStatement, CallableStatement, ResultSet and Driver.Ref : What is JDBC...
4 Feb 2015 by Dr. Song Li
This article presents an example to upload and download files with SQL server through JDBC in a Spring MVC application.
20 Jan 2015 by Shashi14321
import java.sql.*;public class db { Connection con; Statement st; ResultSet rs; public db() { conection(); } public void conection(){ try{ String driver="sun.jdbc.odbc.JdbcOdbcDriver"; ...
18 Jan 2015 by mrcellux
FluentJdbc Query API for more convenient native SQL querying
18 Dec 2014 by PIEBALDconsult
mysql_insert_id()http://dev.mysql.com/doc/refman/5.7/en/mysql-insert-id.html[^]
18 Dec 2014 by Peter Leow
Refer:last inserted id mysql[^]
18 Dec 2014 by DamithSL
check below similar questions and the answers:How do I get the size of a java.sql.ResultSet?[^]How to get row count using ResultSet in Java?[^]
18 Dec 2014 by User 10060665
How can I get the total row count of the table. I'm trying methods of ResultSetMetaData, but it only have getColumnCount(). Is there any other way of getting total count of rows.I'm trying following code, public void...
10 Oct 2014 by Member 10843807
An example to illustrate how esProc Helps Process Structured Text in Java–Conditional Filtering
20 Sep 2014 by JayantaChatterjee
Hi,I am trying to create a Database connection with MSAccess Database in JAVA. I am using JDK 8 & MSAccess 2010(.accdb).this code worked on JDK7 but the error occurred after I upgrade the JDK8.when i run my code its gives an error No suitable driver found for...
15 Sep 2014 by MostafaHelmy
package apptest;import java.sql.*;public class AppTest {// Code s7 Worked public static void main(String[] args) { try { Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); String connectionUrl = "jdbc:sqlserver://localhost:1433;"...
8 Sep 2014 by erw_nda
The link above was dead, the new one is [IT] Connecting JSP with SQL Server 2008 R2 Express (JDBC).
24 Jul 2014 by Jaswanth Reddy
How to perform an CRUD operations of employee details in a text file from stored procedure using oracle db by java programming....Please provide an solution.....Thanks a Ton in Advance......
8 Jun 2014 by Member 10871499
I am trying to connect local db sqlserver 2012 but unable to connect. I am using the below code. Please help to solve this issue.String url = "jdbc:sqlserver://(localdb)\\v11.0;" + "databaseName=sakthi;user=sakthi;password=****;"; ...
6 Jun 2014 by Cesar Bretana Gonzalez
thanks, i have already solve the problem, anyway thanks for the time...