spring-jdbc

Accessing AWS RDS using IAM Authentication and Spring JDBC (DataSource and JdbcTemplace)

两盒软妹~` 提交于 2019-11-30 09:57:20
I am not able to figure out how to implement this. Any help and/or pointers will be greatly appreciated. Currently, my Java/Spring application backend is deployed on EC2 and accessing MySQL on RDS successfully using the regular Spring JDBC setup. That is, storing database info in application.properties and configuring DataSource and JdbcTemplate in @Configuration class. Everything works fine. Now, I need to access MySQL on RDS securely . RDS instance has IAM Authentication enabled. I have also successfully created IAM role and applied inline policy . Then, following the AWS RDS documentation

Spring JdbcTemplate - Insert blob and return generated key

喜你入骨 提交于 2019-11-30 06:54:22
问题 From the Spring JDBC documentation, I know how to insert a blob using JdbcTemplate final File blobIn = new File("spring2004.jpg"); final InputStream blobIs = new FileInputStream(blobIn); jdbcTemplate.execute( "INSERT INTO lob_table (id, a_blob) VALUES (?, ?)", new AbstractLobCreatingPreparedStatementCallback(lobhandler) { protected void setValues(PreparedStatement ps, LobCreator lobCreator) throws SQLException { ps.setLong(1, 1L); lobCreator.setBlobAsBinaryStream(ps, 2, blobIs, (int)blobIn

Spring JDBC RowMapper usage for eager fetches

萝らか妹 提交于 2019-11-30 06:48:10
问题 The question is about the best practice usage for RowMapper in master/detail scenarios where we want to eagerly fetch details using spring jdbc. Assume that we have both Invoice and InvoiceLine classes. public class Invoice{ private BigDecimal invId; private Date invDate; private List<InvoiceLine> lines; } public class InvoiceLine{ private int order; private BigDecimal price; private BigDecimal quantity; } When using Spring Jdbc with a row mapper we usually have a public class InvoiceMapper

Comparing Querydsl, jOOQ, JEQUEL, activejdbc, iciql and other query DSLs

让人想犯罪 __ 提交于 2019-11-29 20:08:14
Can someone point me to some resources about the performance comparison among the different Query DSL libraries available for using with Java, like: Querydsl , jOOQ , JEQUEL , activejdbc , iciql and etc... Background: I m using Spring JDBC template, but that still required the queries to be written in plain string format. Although I don't have issues in writing the direct queries, but I m concerned having direct dependency on DB table names. I don't want to use any ORM framework like Hibernate or JPA/EclipseLink. I need the raw performance as high as possible (IMO, they are good for more CRUD

Spring-Boot, Can't save unicode string in MySql using spring-data JPA

馋奶兔 提交于 2019-11-29 14:41:20
I have my application.properties set up like this : spring.datasource.username = root spring.datasource.password = root spring.datasource.url = jdbc:mysql://localhost:3306/dbname?useUnicode=yes&characterEncoding=UTF-8 spring.datasource.driver-class-name=com.mysql.jdbc.Driver spring.jpa.show-sql = true spring.jpa.hibernate.ddl-auto = update spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect And In my pom.xml I have property set up like this : <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8<

Spring JDBC Could not load JDBC driver class [oracle.jdbc.driver.OracleDriver]

拥有回忆 提交于 2019-11-29 13:12:25
I wonder if any one could help me with this. I encountered an issue when I tried writing code with Spring JDBC. When I ran the server, I got the message like I mentioned in the title. I have google it and someone said that you should import ojdbc.jar. However, I have already imported it. Here comes my code: <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> <bean id="dataSource" class="org

invalid name pattern when trying to pass custom oracle type object mapping

倖福魔咒の 提交于 2019-11-29 07:47:40
Java spring custom Oracle type as a param and getting following error. I don't understand what does that mean by invalid name pattern ? Any help appreciated. org.springframework.jdbc.UncategorizedSQLException: ### Error updating database. Cause: java.sql.SQLException: invalid name pattern: UPSELL.mkt_list_tab ### The error may involve com.comcast.upsell.dao.ProviderAndRegionalDao.getCorpsToMarketsList-Inline ### The error occurred while setting parameters ### SQL: call upsell_tx_etl_report.GET_OFFER_CORPS_TO_MARKETS( ?, ?, ? ) ### Cause: java.sql.SQLException: invalid name pattern: MY_SCHEMA

Spring JdbcTemplate - Insert blob and return generated key

时光毁灭记忆、已成空白 提交于 2019-11-28 23:11:11
From the Spring JDBC documentation, I know how to insert a blob using JdbcTemplate final File blobIn = new File("spring2004.jpg"); final InputStream blobIs = new FileInputStream(blobIn); jdbcTemplate.execute( "INSERT INTO lob_table (id, a_blob) VALUES (?, ?)", new AbstractLobCreatingPreparedStatementCallback(lobhandler) { protected void setValues(PreparedStatement ps, LobCreator lobCreator) throws SQLException { ps.setLong(1, 1L); lobCreator.setBlobAsBinaryStream(ps, 2, blobIs, (int)blobIn.length()); } } ); blobIs.close(); And also how to retrieve the generated key of a newly inserted row :

Spring JDBC RowMapper usage for eager fetches

为君一笑 提交于 2019-11-28 21:34:05
The question is about the best practice usage for RowMapper in master/detail scenarios where we want to eagerly fetch details using spring jdbc. Assume that we have both Invoice and InvoiceLine classes. public class Invoice{ private BigDecimal invId; private Date invDate; private List<InvoiceLine> lines; } public class InvoiceLine{ private int order; private BigDecimal price; private BigDecimal quantity; } When using Spring Jdbc with a row mapper we usually have a public class InvoiceMapper implements RowMapper<Invoice>{ public Invoice mapRow(ResultSet rs, int rowNum) throws SQLException {

How can I config to turn off autocommit in Spring + JDBC?

馋奶兔 提交于 2019-11-28 19:40:58
I am using Spring with JDBC and found that it is autocommit. How can I config to turn it off in spring-servlet.xml? This is my current configuration: <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" p:driverClassName="${jdbc.driverClassName}" p:url="${jdbc.databaseurl}" p:username="${jdbc.username}" p:password="${jdbc.password}" /> <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource"/> </bean> It seems that my configuration missed this line: <tx:annotation-driven