spring-jdbc

JDBC Call to Oracle returns 3 question marks

那年仲夏 提交于 2019-12-10 18:10:14
问题 I do a call to an oracle stored procedure using JDBCTemplate which has an in/out parameter of STRUCT. One of the fields on this struct is a VARCHAR which gets updated depending on the stored procedure logic. However when this is returned from the call it just contains three question marks - '???'. This is possibly the work of the Riddler but it sounds more like a char encoding issue. This worked fine until we switched databases to a database that had a character encoding of WE8ISO8859P15

Spring JDBC - prevent logging - INFO: Added default SqlReturnUpdateCount parameter named #update-count-1

拜拜、爱过 提交于 2019-12-10 17:21:51
问题 My standalone application uses Spring JDBC. I see a lot of the following statements in System.out Mar 28, 2013 6:42:12 PM org.springframework.jdbc.core.JdbcTemplate extractReturnedResults INFO: Added default SqlReturnUpdateCount parameter named #update-count-1 How do I prevent these logs? 回答1: I got around this by skipping the undeclared results, which I don't need anyway JdbcTemplate jt = new JdbcTemplate(dataSource); jt.setSkipUndeclaredResults(true); 回答2: You can write the function call in

Spring jdbc 'select for update'

放肆的年华 提交于 2019-12-10 16:39:41
问题 I have the following method that I use with Spring JDBC public String getState() { String stateLink = template.queryForObject( "select state_url from state_scrape_queue where in_use = false ORDER BY scrape_timestamp NULLS FIRST LIMIT 1", (result, rowNum) -> { return result.getString("state_url"); }); return stateLink; } I can't find an example of how to do a for update with Spring JDBC. I want in_use to be set to true using for update. I need to use select for update since this application

Microservices - Connection Pooling when connecting to a single legacy database

半城伤御伤魂 提交于 2019-12-10 15:52:17
问题 I am working on developing micro services for a monolithic application using spring boot + spring cloud + spring JDBC. Currently, the application is connecting to a single database through tomcat JNDI connection pool. We have a bottleneck here, not to change the database architecture at this point of time because of various reasons like large number of db objects,tight dependencies with other systems,etc. So we have isolated the micro services based on application features. My concern is if

What is the use of this spring class BatchPreparedStatementSetter?

牧云@^-^@ 提交于 2019-12-10 15:38:27
问题 Can anyone give me short description about his spring class org.springframework.jdbc.core.BatchPreparedStatementSetter (JavaDoc API Link) 回答1: It's used for bulk insertion of many rows at once. This code will illustrate how it's used. Take a good look at importEmployees method, and everything should become clear. 回答2: batchUpdate can be done using JdbcTemplate batchUpdate method as follows.. public int[] batchUpdate(final List<Actor> actors) { int[] updateCounts = jdbcTemplate.batchUpdate(

Using mysql database to authenticate users in Spring security?

你。 提交于 2019-12-10 13:22:26
问题 I want to use Spring security to authenticate users in my web application.. Since am not a matured user to Spring framework ,i can't get a clear idea about how we can do the configuration settings to use jdbc-user-service .. i had done the following configurations.but its not working <authentication-manager> <authentication-provider> <jdbc-user-service data-source-ref="myDataSource"/> </authentication-provider> </authentication-manager> <beans:bean id="myDataSource" class="org.apache.commons

How to configure correct timezone in JDBC?

江枫思渺然 提交于 2019-12-10 10:44:12
问题 I've this url to set up the connection in my Italy website, however, when i try to perform some insert action from the site, the date is still not right. (it should be for example: 01:24, but it is 02:24) jdbc.url=jdbc:mysql://sql.example.com/database?autoReconnect=true&characterEncoding=UTF-8&sessionVariables=time_zone='Europe/Rome' Do I need to add any other params to make it work correctly? Is there a complete list of all timezones? 回答1: Sorry I don't have the answer to your direct

java.sql.SQLException: Invalid column name

最后都变了- 提交于 2019-12-10 03:28:59
问题 I cannot figure out why I am getting "Invalid column name" here. We have tried a variant of the sql directly in Oracle, and it works fine, but when I try it using jdbcTemplate then something is wrong. List<Dataholder> alleXmler = jdbcTemplate.query("select p.applicationid, x.datadocumentid, x.datadocumentxml " + "from CFUSERENGINE51.PROCESSENGINE p " + "left join CFUSERENGINE51.DATADOCUMENTXML x " + "on p.processengineguid = x.processengineguid " + "where x.datadocumentid = 'Disbursment' " +

Difference Between Spring JDBC Vs Plain JDBC?

痞子三分冷 提交于 2019-12-09 14:14:19
问题 What is the main difference between Spring JDBC VS JDBC? 回答1: Let me show you some simple example using JDBC: final Connection connection = ds.getConnection(); try { final Statement statement = connection.createStatement(); try { final ResultSet resultSet = statement.executeQuery("SELECT COUNT(*) FROM Orders"); try { resultSet.next(); final int c = resultSet.getInt(1); } finally { resultSet.close(); } } finally { statement.close(); } } finally { connection.close(); } It's much better when try

Spring Jdbc declarative transactions created but not doing anything

五迷三道 提交于 2019-12-09 01:21:43
问题 I have tried to configure declarative transaction management within my Spring-based web application and it refuses to cooperate with me. I have two main problems: Setting defaultAutoCommit to false on our dataSource (which we need for our application) causes all queries to rollback, with or without transactions being involved. Transactions are configured and proxy classes as well as transactional methods are created, however no transactions appear to be used. The first problem is rather