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.

JDBC is a Java-based data access technology (Java Standard Edition platform) from Oracle Corporation.

This technology is an API for the Java programming language that defines how a client may access a database. It provides methods for querying and updating data in a database. JDBC is oriented towards relational databases. A JDBC-to-ODBC bridge enables connections to any ODBC-accessible data source in the JVM host environment.

Online resources

Frequently asked questions

Related tag info pages

  • - another abstract layer over JDBC
  • - a part of data access layer with hidden low-level details privided by Spring
  • - JDBC-to-ODBC bridge
  • - JDBC driver for Oracle DB
  • - JDBC driver for MS SQL Server
  • - JDBC driver for PostgreSQL
  • - MySQL connectors including JDBC
  • - JDBC driver for Firebird
33118 questions
156
votes
10 answers

How does a PreparedStatement avoid or prevent SQL injection?

I know that PreparedStatements avoid/prevent SQL Injection. How does it do that? Will the final form query that is constructed using PreparedStatements be a string or otherwise?
Prabhu R
  • 13,836
  • 21
  • 78
  • 112
143
votes
14 answers

PreparedStatement with list of parameters in a IN clause

How to set value for in clause in a preparedStatement in JDBC while executing a query. Example: connection.prepareStatement("Select * from test where field in (?)"); If this in-clause can hold multiple values how can I do it. Sometimes I know the…
Harish
  • 3,343
  • 15
  • 54
  • 75
141
votes
6 answers

Caused by: java.lang.Exception: No native library is found for os.name=Mac and os.arch=aarch64. path=/org/sqlite/native/Mac/aarch64

I am using Android Studio [Android Studio Arctic Fox | 2020.3.1 Patch 1] My room library version is [2.3.0] Used Gradle version [7.0.1] Also added kapt 'org.xerial:sqlite-jdbc:3.36.0.1' Caused by: java.lang.Exception: No native library is found…
Roman
  • 2,464
  • 2
  • 17
  • 21
136
votes
7 answers

MySQL 'create schema' and 'create database' - Is there any difference

Taking a peek into the information_schema database and peeking at the metadata for one of my pet projects, I'm having a hard time understanding what (if any) differences there are between the create schema command and the create database command for…
Bob
  • 2,002
  • 3
  • 16
  • 18
128
votes
14 answers

What is the MySQL JDBC driver connection string?

I am new to JDBC and I am trying to make a connection to a MySQL database. I am using Connector/J driver, but I cant find the JDBC connection string for my Class.forName() method.
ravi kumar
127
votes
14 answers

java.sql.SQLException: - ORA-01000: maximum open cursors exceeded

I am getting an ORA-01000 SQL exception. So I have some queries related to it. Are maximum open cursors exactly related to number of JDBC connections, or are they also related to the statement and resultset objects we have created for a single…
Kanagavelu Sugumar
  • 18,766
  • 20
  • 94
  • 101
126
votes
23 answers

ORA-01882: timezone region not found

I'm accessing an Oracle Database from a java application, when I run my application I get the following error: java.sql.SQLException: ORA-00604: error occurred at recursive SQL level 1 ORA-01882: timezone region not found
ndalama
  • 1,635
  • 3
  • 17
  • 15
126
votes
21 answers

The infamous java.sql.SQLException: No suitable driver found

I'm trying to add a database-enabled JSP to an existing Tomcat 5.5 application (GeoServer 2.0.0, if that helps). The app itself talks to Postgres just fine, so I know that the database is up, user can access it, all that good stuff. What I'm trying…
Rick Wayne
  • 1,503
  • 2
  • 12
  • 11
125
votes
13 answers

How to establish a connection pool in JDBC?

Can anybody provide examples or links on how to establish a JDBC connection pool? From searching google I see many different ways of doing this and it is rather confusing. Ultimately I need the code to return a java.sql.Connection object, but I am…
llm
  • 5,539
  • 12
  • 36
  • 30
124
votes
3 answers

Closing JDBC Connections in Pool

Our standard code section for using JDBC is... Connection conn = getConnection(...); Statement stmt = conn.conn.createStatement (ResultSet.TYPE_SCROLL_INSENSITIVE, …
Manidip Sengupta
  • 3,573
  • 5
  • 25
  • 27
124
votes
3 answers

What does java:comp/env/ do?

I just spent too much time of my day trying to figure out some errors when hooking up some JNDI factory bean. The problem turned out to be that instead of this...
Danny
  • 3,670
  • 12
  • 36
  • 45
124
votes
11 answers

Cannot issue data manipulation statements with executeQuery()

In MySQL I have two tables, tableA and tableB. I am trying to execute two queries: executeQuery(query1) executeQuery(query2) But I get the following error: can not issue data manipulation statements with executeQuery(). What does this mean?
silverkid
  • 9,291
  • 22
  • 66
  • 92
123
votes
3 answers

Should I use java.util.Date or switch to java.time.LocalDate

Edit: Well, apparently it was too opinion based, so let me try to reword it more precisely - Are there any clear caveats or drawbacks of using LocalDate, LocalTime etc. in a Java code that does not need any backwards compatibility, and if so - what…
Itai
  • 6,641
  • 6
  • 27
  • 51
122
votes
6 answers

Multiple queries executed in java in single statement

Hi I was wondering if it is possible to execute something like this using JDBC as it currently provides an exception even though it is possible in the MySQL query browser. "SELECT FROM * TABLE;INSERT INTO TABLE;" While I do realize that it is…
MilindaD
  • 7,533
  • 9
  • 43
  • 63
117
votes
18 answers

How to convert TimeStamp to Date in Java?

How do I convert 'timeStamp' to date after I get the count in Java? My current code is as follows: public class GetCurrentDateTime { public int data() { int count = 0; java.sql.Timestamp timeStamp = new…
Krishna Veni
  • 2,217
  • 8
  • 27
  • 53