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
7
votes
4 answers

SQLite JDBC driver on Android

I'm trying to use xerial sqlite-jdbc to manage my database in Android with no success.I'm getting an java.lang.NoClassDefFoundError: org.sqlite.SQLiteConnection exception.I've imported this dependency 'org.xerial:sqlite-jdbc:3.18.0' in my gradle. My…
tasgr86
  • 299
  • 2
  • 7
  • 17
7
votes
1 answer

PreparedStatement.addBatch in java has any restrictions?

I'm trying to optimize the process of inserting a large number of results to a remote mySQL database. I'm using simple jdbc for that. Currently I'm replacing exiting statements with PreparedStatement and execute methods with addBatch/executeBatch…
adiian
  • 1,382
  • 2
  • 15
  • 32
7
votes
4 answers

JDBC Thin connection string in Oracle uses both colon and forward slash

I wanted to know can we use both colon and forward slash with SID in making the connection URL in Oracle? e.g. jdbc:oracle:thin:@:1521: jdbc:oracle:thin:@:1521/ Will these two are same and will work? I am building an…
Deepak Jain
  • 305
  • 1
  • 3
  • 19
7
votes
1 answer

Spark reading from Postgres JDBC table slow

I am trying to load about 1M rows from a PostgreSQL database into Spark. When using Spark it takes about 10s. However, loading the same query using psycopg2 driver takes 2s. I am using postgresql jdbc driver version 42.0.0 def…
7
votes
3 answers

If I restart the Rest server, H2 database reset

I used file db as below: spring.datasource.url=jdbc:h2:file:./data/meet And I can find file "meet.mv.db" in my working directory. If I add tuples to the file and restart the server, the size of the file increases. However, I cannot get what is…
John
  • 1,139
  • 3
  • 16
  • 33
7
votes
3 answers

What is a datasource in java? Can someone please explain me in simple language?

What is a DataSource in java? Can someone please explain me in simple language?
Shubham Arya
  • 585
  • 5
  • 18
7
votes
4 answers

Read an ARRAY from a STRUCT returned by a stored procedure

In the database are three Oracle custom types (simplified) as follows: create or replace TYPE T_ENCLOSURE AS OBJECT( ENCLOSURE_ID NUMBER(32,0), ENCLOSURE_NAME VARCHAR2(255 BYTE), ANIMALS T_ARRAY_ANIMALS, MEMBER FUNCTION …
DerMike
  • 15,594
  • 13
  • 50
  • 63
7
votes
1 answer

Why does JDBC adjust the time to default timezone when it is saving a date?

This question is related to this but this specific question focuses on the why. So no, this isn't a duplicate. Quoting the answer: The problem is that Java Date objects don't store a time zone. The value is always in UTC, and is parsed and…
supertonsky
  • 2,563
  • 6
  • 38
  • 68
7
votes
3 answers

How to test if JDBC driver is installed correctly and if the DB can be connected?

I tried installing this at home along with Java SDK... The SDK worked fine and I can now use the command prompt to compile java programs into classes... However I am unsure how to test if JDBC is working to connect to my server/databases/mysql. As I…
James Andrew
  • 7,197
  • 14
  • 46
  • 62
7
votes
1 answer

What's the correct way to escape the ? character in a JDBC PreparedStatement when using Oracle 12c MATCH_RECOGNIZE?

The following query is correct in Oracle 12c: SELECT * FROM dual MATCH_RECOGNIZE ( MEASURES a.dummy AS dummy PATTERN (a?) DEFINE a AS (1 = 1) ) But it doesn't work through JDBC because of the ? character that is used as a regular expression…
Lukas Eder
  • 211,314
  • 129
  • 689
  • 1,509
7
votes
3 answers

How PreparedStatement Works Internally in Java: How compilation & caching of SQL works

I read about it in the internet but I am not able to get answer for some queries. Q1. It is said that when the PreparedStatement is executed, the DBMS can just run the PreparedStatement SQL statement without having to compile it first. My question…
Sumit
  • 856
  • 5
  • 18
  • 38
7
votes
0 answers

I can't make the sqljdbc work with AD username/password

I need to connect to High Availability (HA) / Desaster Recovery (DR), also known as HADR, enabled SQL server 2012 using AD account from Java on Linux. integratedSecurity is not an option since it runs on Linux I can not use the jTDS JDBC driver…
Hurda
  • 4,647
  • 8
  • 35
  • 49
7
votes
2 answers

How to write into PostgreSQL hstore using Spark Dataset

I'm trying to write a Spark Dataset into an existent postgresql table (can't change the table metadata like column types). One of the columns of this table is of type HStore and it's causing trouble. I see the following exception when I launch the…
bachr
  • 5,780
  • 12
  • 57
  • 92
7
votes
3 answers

How do I sort a VARCHAR column in PostgreSQL that contains words and numbers?

I need to order a select query using a varchar column, using numerical and text order. The query will be done in a java program, using jdbc over postgresql. If I use ORDER BY in the select clause I obtain: 1 11 2 abc However, I need to obtain:…
Angel Palazon
  • 369
  • 1
  • 5
  • 16
7
votes
2 answers

What is the best way to rollback() a statement execution failure in Java 8?

I'm writing a transaction with Java 8. First, my code was like this. try (Connection conn = DAOUtil.getConnection(); PreparedStatement ps = conn.prepareStatement(addSubscriptionSql)) { conn.setAutoCommit(false); //do work …
Bee
  • 12,251
  • 11
  • 46
  • 73
1 2 3
99
100