Skip to content

Tag: jdbc

How does JDBC DataSource works?

I wondered how works method getConnection() at DataSource? I assume that DataSource calling DriverManager.getConnection every time when we call DataSource.getConnection with our properties that we setting in DataSource. Is that true? Answer The answers to your question can be deduced from the DataSource javadoc. “The DataSource interface is implemented by a driver vendor. There are three types of implementations: Basic

Spring jpa database connection for native query

I have a spring application that have to connect to a sql server db. There are no @Entity class and there ate no @Repository because the tables and the columns of the tables are unknown to the application. I have created a class and used an entity manager to execute queries, but I’m not sure this is the best choice

PrearedStatement executeUpdate() is not working

I’m new to JDBC and using the following code to update the row using MySQL JDBC driver. I have no idea why executeUpdate() is not updating the content in the database. Can anyone help me? Answer Your query string is wrong. It should be something like this: Look here for the proper syntax of update: Also if you want

Provide SSL certificate to SQL Server via JDBC

The Microsoft JDBC SSL documentation details the use of a Java keystore in order to specify a certificate bundle to use when validating the TLS connection. Is there a way to provide a certificate bundle without needing to store it within a JKS when connecting to a SQL Server database? Postgres seems to have a sslrootcert option which appears to

How to get list of Map data using JDBCTemplate.queryForMap

How I can get proper return type of List<Map<String, Object>> mapList = jdbctemplate.queryForList(query)); Where my query is “SELECT * FROM table_name;”. Can anyone help me? Answer You can use the following snippet to get the required map from the list: -> (Integer) k.get(“id”), k -> (String) k.get(“name”))); this is used to extract the exact data alone from the whole

Mapping between DB2 XML CLOB data type and DB2 JDBC types are keep changing as upgrading to different JDBC versions

We were using v10.1 and recently we have upgraded it with the V11.1.4 FP5 driver for the z/OS Db2 systems. When we were using v10.1 the equivalent JDBC java class for DB2 XML CLOB was and now after upgrading it with V11.1.4 FP5 driver now, it changed to However in latest version v11.5 M7 FP0 it’s

Check if any value in list satisfies a condition

Suppose I have the following table called Seasons: … start_month end_month … 2 6 … 3 4 … … … I need to write a query which, for a given list of months, returns all the Seasons that satisfy the condition where at least 1 month in the list is: start_month <= month <= end_month. I’ve written this query as