spring-jdbc

HSQL database user lacks privilege or object not found error

帅比萌擦擦* 提交于 2019-12-17 18:34:24
问题 I am trying to use hsqldb-2.3.4 to connect from Spring applicastion. I created data base using the following details Type : HSQL Database Engine Standalone Driver: org.hsqldb.jdbcDriver URL: jdbc:hsqldb:file:mydb UserName: SA Password: SA I created a table named ALBUM under "MYDB" schema In spring configuration file: <bean id="jdbcTemplate" class="org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate"> <constructor-arg ref="dbcpDataSource" /> </bean> <bean id="dbcpDataSource"

multiple one-to-many relations ResultSetExtractor

怎甘沉沦 提交于 2019-12-17 17:54:13
问题 Let's say I have an object with two different one-to-many relations. Much like: Customer 1<->M Brands and Customer 1<->M Orders And let's say that the my object Customer has two lists related to those two objects. I've read this example: http://forum.springsource.org/showthread.php?50617-rowmapper-with-one-to-many-query which explains how to do it with a single one-to-many relationship. For your convenience here's the ResultSetExtractor override: private class MyObjectExtractor implements

How to do multiple inserts in database using spring JDBC Template batch?

天大地大妈咪最大 提交于 2019-12-17 15:35:23
问题 I need to insert thousands of records in the database at one go. I am using spring JDBC template in my application. Below is the code I have written so far which executes all inserts at one go. So, if I ahve 10,000 users they are inserted at one go. But what I want is to execute them in batches say for example 500 records in one batch and so on. @Override public void saveBatch(final List<Employee> employeeList) { final int batchSize = 500; getJdbcTemplate().batchUpdate(QUERY_SAVE, new

NamedParameterJdbcTemplate vs JdbcTemplate

落花浮王杯 提交于 2019-12-17 07:14:10
问题 I'm a beginner to Spring3.x , I'm learning Spring DAO support. I want to know the difference between NamedParameterJdbcTemplate and JdbcTemplate. Which one is the best by means of performance. And when to go for NamedParameterJdbcTemplate and when to go for JdbcTemplate. Your answer will help a lot to the beginners like me. 回答1: When you use JdbcTemplate you give it SQL that has a ? placeholder for each parameter you want substituted into the SQL. When you assign parameters in the code you

Spring boot connection pool autoconfiguration for more than one datasource

守給你的承諾、 提交于 2019-12-13 19:11:39
问题 I have a web application written using spring boot and Spring batch job which reads from CSV and writes data to RDS ( With MySQL engine ) table using spring jdbcTemplate. I have separated the spring batch specific job meta data tables to separate database so as to avoid confusion with my business logic tables. I need to bring connection pool capability for both the databases. I am using default connection pool provided by spring boot ( Tomcat jdbc pool ). I am configuring the multiple

Spring JDBC template without Spring

南笙酒味 提交于 2019-12-13 12:25:37
问题 Is there Java library like Spring JDBC Template, with same quality of code and documentation and similar data access exceptions hierarchy , but without dependancies on other Spring modules (core/beans/context modules according to http://mvnrepository.com/artifact/org.springframework/spring-jdbc/3.0.6.RELEASE)? 回答1: Spring-jdbc has direct dependency to the following libraries: spring-core , spring-beans and spring-tx . The rest of the dependencies are optional, so you don't need them actually.

What's the appropriate way to test code that uses MySQL-specific queries internally

*爱你&永不变心* 提交于 2019-12-13 12:04:21
问题 I am collecting data and store this data in a MySQL database using Java. Additionally, I use Maven for building the project, TestNG as a test framework, and Spring-Jdbc for accessing the database. I've implemented a DAO layer that encapsulates the access to the database. Besides adding data using the DAO classes I want to execute some queries which aggregate the data and store the results in some other tables (like materialized views). Now, I would like to write some testcases which check

Spring NamedParameterJdbcTemplate not returning result for simple query

£可爱£侵袭症+ 提交于 2019-12-13 07:57:43
问题 Please bare with my limited info on code since having limited access to copy paste complete code. @Repository("BaseDao") public class BaseDaoImpl implements BaseDao{ public NamedParameterJdbcTemplate namedJdbcTemplate; @Autowired public void setDataSource(DataSource dataSource){ this.namedJdbcTemplate = new NamedParameterJdbcTemplate(dataSource); } } @Repository("WelcomeDao") public class WelcomeDaoImpl extends BaseDaoImpl implements WelcomeDao { public List<String> getFunctionTypes() {

Spring 4 JDBC - How to load DB Properties and optimize (using Cache or DB Connection Pool)

半腔热情 提交于 2019-12-13 03:43:53
问题 Am maintaining a codebase which was written in Spring MVC 4.3.9.RELEASE (not Spring Boot)... Under src/main/resources: There are two different database configuration files: sampledb.xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org

Is there a generic way of getting columns in ResultsSet of MapRow

风流意气都作罢 提交于 2019-12-13 02:48:07
问题 I am using SimpleJdbcTemplate and for example I have something like this: @Override public Variant mapRow(ResultSet rs, int rowNum) throws SQLException then I am getting the values from this result set with lines of code like this: variant.setName(rs.getString("variant_name")); so I have to look at my table, see what type should I use for each column, - getString for String in this example - ...so I will have getString, getLong, getInt,... I was wondering if there a more generic way of