spring-jdbc

Spring boot jdbc Connection

一个人想着一个人 提交于 2019-12-13 00:55:03
问题 i'm trying to configure spring boot in order to have tomcat connection pool to my production database. My application is NOT web (i have also some difficult to tell that to spring). I have a Startup class and 3 more classes the code @Configuration @EnableAutoConfiguration(exclude = DataSourceAutoConfiguration.class) public class Starter { private static Logger logger; @Autowired private static MyController controller; public static void main(String[] args) { // SpringApplication

Reading a BLOB using JDBC Spring without a result set

六眼飞鱼酱① 提交于 2019-12-13 00:48:07
问题 I have an Oracle stored procedure that returns a BLOB in an output parameter: PROCEDURE GET_IMAGE_DATA(i_image_type IN NUMBER, o_image_data OUT BLOB) IS BEGIN SELECT IMAGE_DATA INTO o_image_data FROM IMAGES WHERE IMAGE_TYPE = i_image_type; END GET_IMAGE_DATA; I want to use JDBC Spring to read this data. However, DefaultLobHandler (and I think OracleLobHandler) getBlobAsBytes() requires a resultset. private static class QueryForBinaryCryptKey extends StoredProcedure { private static final

facing issue while starting spring boot using hikaricp

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-12 22:42:27
问题 I have done the same, as some blogs have suggested. But still I couldn't able to solve the issue. Environment: spring - 4.2.5.RELEASE spring boot - 1.3.3.RELEASE hikariCP - 2.4.7 @Bean(name="HikariDataSource",destroyMethod = "shutdown") public DataSource dataSource2() { HikariConfig config = new HikariConfig(); config.setDriverClassName("oracle.jdbc.OracleDriver"); config.setJdbcUrl(""); config.setUsername(""); config.setPassword(""); config.addDataSourceProperty("cachePrepStmts", "true");

How to execute custom sql code in every transaction managed by spring DataSourceTransactionManager?

我的梦境 提交于 2019-12-12 18:12:12
问题 Consider situation in which we have tons of java DAO classes managed by Spring. Every method defined in those beans executes SQL code in Spring's Datasource transaction, defined by annotation on a method. Now we have a requirement to run some custom code just before target execution of mentioned methods, this code MUST be executed in the same transaction as defined by annotation on target method. Update based on R4J comment: My proxy for DAO calls which should call procedure PR_Adm_Set_Usr in

What is the Spring 5 JDBC approach when nativeJdbcExtractor is needed?

China☆狼群 提交于 2019-12-12 13:40:19
问题 I have just upgraded Spring/SpringBoot dependencies and noticed that class JdbcTemplate does not have property "nativeJdbcExtractor" any more. I was able to find the details and background: https://jira.spring.io/browse/SPR-14670 However I was not able to find the replacement configuration. I use commons-dbcp library and Spring classes like SimpleJdbcCall etc. I never deal with low level JDBC API, however if the vendor code needs its real Connection type (Oracle) the nativeJdbcExtractor

Spring JdbcTokenStore doesn't store/ create tokens. (Failed to fetch token)

怎甘沉沦 提交于 2019-12-12 10:58:13
问题 So I've been trying for over a week to get the JdbcTokenStore to work, but I can't seem to figure out what is wrong. I'm not using spring boot and I'll try my best to explain what I'm doing. So let's start with the database for the tokens: I'm using PostgreSQL which is why I use BYTEA DROP TABLE IF EXISTS oauth_client_details; CREATE TABLE oauth_client_details ( client_id VARCHAR(255) PRIMARY KEY, resource_ids VARCHAR(255), client_secret VARCHAR(255), scope VARCHAR(255), authorized_grant

Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'test.spring_session' doesn't exist - Spring Boot

对着背影说爱祢 提交于 2019-12-12 09:35:08
问题 I am developing springboot-springsession-jdbc-demo . When I simply run the code I get the following error. It looks to me some property must need to set in application.properties in order create the schema/tables before hand. Required configuration is already in placed and still it gives error. The code is present in https://github.com/sivaprasadreddy/spring-session-samples The error for reference: org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar

Error: "Connection refused: connect. Verify the connection properties

浪尽此生 提交于 2019-12-12 04:56:16
问题 The TCP/IP connection to the host localhost, port 1433 has failed. Error: "Connection refused: connect. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.". I have Checked the SQL Server Configuration Manager TCP/IP is Enabled.But Still I am Facing same issue.I have added sqljdbc4.0.jar <property name="driverClassName" value=

Need spring jdbc resultset to return list of objects instead of LinkedHashMap

霸气de小男生 提交于 2019-12-12 04:36:46
问题 I am using with a row mapper expecting it wuold return me the list of my objects but instead it is returning me LinkedHasMap. I want resultset to be List of my mapped objects. Any idea how can i achieve this ? Config <int-jdbc:stored-proc-inbound-channel-adapter channel="eventObj" stored-procedure-name="p_get_completed_data" data-source="dataSource" auto-startup="true" id="completedEventAdpt" ignore-column-meta-data="true" is-function="false" return-value-required="false"> <int:poller max

Spring connection pool, JdbcTemplate, Hibernate and abandoned connections

二次信任 提交于 2019-12-12 04:02:40
问题 My Spring Boot 1.3.2.RELEASE app is using both Hibernate and JDBC (using JdbcTemplate). This is running on Java 8. The JDBC driver is Oracle ojdbc7 12.1.0.1. It is configured to use Spring connection pooling. I recently switched from c3p0 which worked. When I test the new configuration (no c3p0) it under load, it quickly allocates all the connections I set it to (max 50, I used netstat to count) and then I start to see many abandoned connection exceptions. Then I start to get exceptions