SimpleJdbcTemplate « Database « Spring Q&A





1. SimpleJdbcTemplate and null parameters    stackoverflow.com

I'm using SimpleJdbcTemplate and MapSqlParameterSource in the folowing way:

MapSqlParameterSource parameterSource = new MapSqlParameterSource();
parameterSource.addValue("typeId", typeId, Types.BIGINT);

List<Long> ids = _jdbcTemplate.query(_selectIdByParameters, new EntityIdRowMapper(), parameterSource);
When typeId ( which is a Long ) is null, then ...

2. How do I setQueryTimeout on SimpleJdbcTemplate?    stackoverflow.com

The Spring Framework has two similar classes: JdbcTemplate is the old, Java 1.4 class, and SimpleJdbcTemplate is newer, with nicer methods. JdbcTemplate has a method setQueryTimeout, which basically gives me ...

3. Get list of all table names from spring SimpleJdbcTemplate    stackoverflow.com

Is there a way to obtain the list of all table names in the database using Spring's SimpleJdbcTemplate? The database being queried is Oracle if that helps in any way. Thanks. ...

4. simpleJdbcTemplate. - insert and retrieve ID    stackoverflow.com

I'm putting the data into database with simpleJdbcTemplate.

simpleJdbcTemplate.update("insert into TABLE values(default)");
I dont want to put any data because i dont need it for my unit test purpose. How can i get the ...

5. simpleJDBCTemplate not replacing quoted parameter    stackoverflow.com

I am using simpleJDBCTemplate to insert a value to a postgre database.

String sql "insert into testTable values(:bla, :blah, functionThatTakesAText(':blu'))"
BeanPropertySqlParameterSource namedParameters = new BeanPropertySqlParameterSource(lighting);
simpleJdbcTemplate.update(sql, namedParameters);
Now, the blu parameter is actually a number(the ...

6. How to measure time to execute a query when using SimpleJdbcTemplate    stackoverflow.com

  • The only solution I can come up with is to write a decorator class that decorates each and every method of SimpleJdbcTemplate, and logs the time taken.
  • Do you have any thing ...

7. Is the SimpleJdbcTemplate in Spring safe from SQL Injection?    stackoverflow.com

I realise it's possible to pass in a manually constructed String to the execute(String) which is vulnerable. However I'm interested in where you pass the parameters to the query using ...

8. How to use the SimpleJdbcTemplate queryForMap    stackoverflow.com

Is there a way to get a Map<String,Integer> for instance? The call seems to return only a Map<String, Object> which I can't cast to Map<String,Integer>.

9. Spring JUnit and Mockito - SimpleJdbcTemplate    stackoverflow.com

Given a class that extends SimpleJdbcDaoSupport, how can you mock SimpleJdbcTemplate?

public class SimpleJdbcDaoSupportExtension extends SimpleJdbcDaoSupport {  
     public SimpleJdbcDaoSupportExtension (JdbcTemplate jdbcTemplate){  
    ...





10. SimpleJdbcTemplate not serializable    stackoverflow.com

I use JSF and Spring. The JSF beans must be serializable by design. The JSF beans get injected with Spring beans that handle the db access. Thus these beans must be ...

11. Large list returned from a SimpleJdbcTemplate query    stackoverflow.com

here is my problem : at some point in my Java program, I get a (very) big List of Events from a database using the SimpleJdbcTemplate class from Spring.

List<Event> events = ...

12. Spring SimpleJdbcTemplate: java.lang.OutOfMemoryError: GC overhead limit exceeded    stackoverflow.com

I'm dipping my toe into Spring and I've been using the SimpleJdbcTemplate to help reduce the amount of code I need to write but I now have an issue where the ...

13. simpleJdbcTemplate multiple row fetch    stackoverflow.com

I'm using SimpleJdbcTemplate to fetch a list of records from a database. Each record corresponds to a data model object. I have searched in the internet a lot but I still can't ...

14. ItemWriter, SimpleJdbcTemplate & timezone pain    forum.springsource.org

ItemWriter, SimpleJdbcTemplate & timezone pain Hi all, I'm running into a problem that I believe has more to do with Spring JDBC than Spring Batch, but I'm asking here because it's ...

15. SimpleJdbcTemplate    forum.springsource.org

SimpleJdbcTemplate Hello guys, what is the best way to map a row with a composite key? Has anyone a good sample? Does i have to implement two row mappers (one for ...

16. SimpleJdbcTemplate batchUpdate returns strange values    forum.springsource.org

SimpleJdbcTemplate batchUpdate returns strange values After a successful run of SimpleJdbcTemplate.batchUpdate all the values are -2 in the array that returns the number of rows affected by each update in the ...





17. SimpleJdbcTemplate Examples?    forum.springsource.org

Are there any examples of using SimpleJdbcTemplate? Looks like the sample app uses iBatis. Just wanted a template implementation to base mine off of if one was available.

18. is it bug in SimpleJdbcTemplate    forum.springsource.org

is it bug in SimpleJdbcTemplate Hello, I've done one DAO that writes to Access database data using SimpleJdbcTemplate with Java 5 of course. Spring wersion is 2.0M4 So, when i'm doing ...

19. simpleJdbcTemplate newbie help    forum.springsource.org

simpleJdbcTemplate newbie help hi all i have this working code before shifting to spring-framework-2.0-rc2 . . . Code: public Collection getPhonePlans(){ String sql = " select " + FIELDS + "from ...

20. SimpleJdbcTemplate IoC Error    forum.springsource.org

SimpleJdbcTemplate IoC Error Hi Guys, How do I inject a SimpleJdbcTemplate? I got this error starting my tomcat engine Code: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'simpleJdbcTemplate' defined in ServletContext resource ...

21. SimpleJdbcTemplate iteration through results    forum.springsource.org

SimpleJdbcTemplate iteration through results Hi, If I am using the SimpleJdbcTemplate, have a Mapper and expect to return multiple rows, where would the loop go? Something like this?: Code: public ArrayList ...

22. SimpleJdbCTemplate returning wrong number of results    forum.springsource.org

SimpleJdbCTemplate returning wrong number of results I noticed that when using SimpleJdbcTemplate with a passed in parameter it would return a different number of results (none) then if I constructed the ...

23. How many instances of SimpleJdbcTemplate should be created?    forum.springsource.org

How many instances of SimpleJdbcTemplate should be created? Hello, as a beginner with Spring JDBC support, I have indeed several questions under this naive title. 1) Is SimpleJDBCTemplate thread-safe? If it ...

24. EmptyResultDataAccessException, SimpleJdbcTemplate    forum.springsource.org

EmptyResultDataAccessException, SimpleJdbcTemplate Hi, I use the SimpleJdbcTemplate to query for an object (User) with a specified email address. I use the queryForObject method... This works fine when a User with the ...

25. SimpleJdbcTemplate.queryForObject    forum.springsource.org

Does the sql string become a prepared statement for this overloaded method? It's not clear from the javadoc that it is or isn't - if I follow the see also javadoc ...

26. Question on Object [] args parameter in SimpleJdbcTemplate.query method    forum.springsource.org

Greetings, I have a question on the Object [] args parameter of the SimpleJdbcTemplate's query method - What impact does setting the arguments have on the query that is executed? The ...

27. Sticky connection when using SimpleJdbcTemplate and dbcp?    forum.springsource.org

Sticky connection when using SimpleJdbcTemplate and dbcp? When using SimpleJdbcTemplate and a dbcp datasource - is it possible to send multiple queries using the exact same connection as the previous call? ...

28. AbstractTransactionalJUnit4SpringContextTests & SimpleJdbcTemplate    forum.springsource.org

I cannot seem to find how to gain access to the SimpleJdbcTemplate property of AbstractTransactionalJUnit4SpringContextTests in a static fashion. It would be nice to be able to use @BeforeClass and @AfterClass ...

29. ClassCastException - SimpleJdbcTemplate    forum.springsource.org

Dear All, When querying the database (MySQL in my case) using SimpleJdbcTemplate (queryForMap or queryForList) it returns Map keyed on the field of the table. A field is defined in ...

30. Mocking the SimpleJdbcTemplate [Jira-Issue SPR-4454]    forum.springsource.org

Mocking the SimpleJdbcTemplate [Jira-Issue SPR-4454] Hey all, I started a feature request with an issue yesterday in Jira about to have the ability to mock the SimpleJdbcTemplate in the class org.springframework.jdbc.core.simple.SimpleJdbcDao ...

31. Problems with NULL values with SimpleJdbcTemplate on DB2    forum.springsource.org

Problems with NULL values with SimpleJdbcTemplate on DB2 When trying to make updates with SimpleJdbcTemplate: getSimpleJdbcTemplate().update("INSERT INTO jiveGroup (name, description, groupID, creationDate, modificationDate) VALUES (?, ?, ?, ?, ?)", group.getName(), group.getDescription(), ...

32. SimpleJdbcTemplate equivalent for JdbcTemplate.setFetchSize    forum.springsource.org

SimpleJdbcTemplate equivalent for JdbcTemplate.setFetchSize I have a query where I am expecting to get a large number of results. When using JdbcTemplate, I would set the fetch size to help optimize. ...

33. NullPointerException: SimpleJDBCTemplate doesn't find my datasource    forum.springsource.org

NullPointerException: SimpleJDBCTemplate doesn't find my datasource Probably a very simple misstake but I cant figure it out, jdbcTemplate never get initiated, ie always throws a NullPointerException. applicationcontext.xml: Code: ...

34. How to use SimpleJdbcTemplate#query without arguments    forum.springsource.org

Hi, i am using SimpleJdbcTemplate to query the database with the following sql statement "select state from States". This returns a resultset of varchar states. no arguments are required. How do ...

35. SimpleJdbcTemplate - batchUpdate method    forum.springsource.org

SimpleJdbcTemplate - batchUpdate method - Bug? Hello all, I am using BatchUpdate method in SimpleJdbcTemplate and using it to insert and delete rows in to Oracle database. I am using this ...

36. SimpleJDBCTemplate -> Many results but need one Object?!    forum.springsource.org

SimpleJDBCTemplate -> Many results but need one Object?! For tables that have many columns and each row can be a new object, this works just fine. Unfortunately, I have a table ...

37. advice for SimpleJdbcTemplate    forum.springsource.org

We need to audit log every sql query that is being executed in application. When I used the following aspect in my aspect class it is not working: @Before("execution(* org.springframework.jdbc.core.simple.SimpleJdbcTem plate.*(..))") ...

38. SimpleJdbcTemplate bad Conversion of TINYINT type    forum.springsource.org

SimpleJdbcTemplate bad Conversion of TINYINT type Hi ! I'm using this method to find value in database like this: Code: this.simpleJdbcTemplate.queryForList(getSELECTCOL(), arg); according to List> queryForList(String sql, Map args) For all ...

39. SimpleJDBCTemplate.query : IN (?) with a List    forum.springsource.org

You are probably better of with a custom thing that replaces the single ? with a number of ? which matches the number of elements in your list. That way you ...

40. simpleJdbcTemplate with postgress    forum.springsource.org

Sep 10th, 2008, 02:26 PM #1 martinppp View Profile View Forum Posts Private Message Junior Member Join Date Apr 2008 Posts 9 simpleJdbcTemplate with postgress I use simpleJdbcTemplate to do an ...

41. Performance issue of SimpleJdbcTemplate?    forum.springsource.org

Performance issue of SimpleJdbcTemplate? The code segement is as following final String sql = "SELECT * FROM TICKER(NOLOCK) WHERE ID = ? AND DATETIME = ? "; final String dateStr = ...

42. is SimpleJdbcTemplate thread-safe?    forum.springsource.org

Yes it can be used across all threads. The normal situarion is to have a base DAO with a reference to the singleton JDBCTemplate. The JDBCTemplate has properties that can be ...

43. SimpleJdbcTemplate and cglib proxy    forum.springsource.org

SimpleJdbcTemplate and cglib proxy Hi, I am trying to define some aspects in my application and I had to turn cglib proxy generation on. However I have the following Code: Caused ...

44. SimpleJdbcTemplate missing operation batchUpdate(String sql, List batchArgs    forum.springsource.org

SimpleJdbcTemplate missing operation batchUpdate(String sql, List batchArgs Hi all, I'm new to Spring and so downloaded the spring with dependencies module I was then trying to create a Simple Dao that ...

45. SimpleJdbcTemplate having trouble with char parameter    forum.springsource.org

Trouble with SimpleJdbcTemplate and char parameter I have been using SimpleJdbcTemplate for a year now, and it has been working out great for me until I ran into this issue yesterday. ...

46. SimpleJdbcTemplate and autocommit    forum.springsource.org

SimpleJdbcTemplate and autocommit Hello, In my application DAOs I'm trying to use SimpleJdbcTemplate and HSQLDB in file mode, with no transaction. I'm afraid autocommit doesn't work because changes to the database ...

47. simplejdbctemplate and (mysql) regular expressions    forum.springsource.org

this.jdbcTemplate.queryForList("select * from atable where acolumn like ?%",new Object[]{"someString"}); This does not work. It doesn't throw any errors even. It just doesn't work at all. Why doesn't SimpleJdbcTemplate work with regular ...

48. SimpleJdbcTemplate - elegant way to get a List from single column query?    forum.springsource.org

Hello, Let's say I'm selecting a single column from many rows within a table using the SimpleJdbcTemplate. Is there an elegant way to get this as a List? Usually I'd use ...

49. SimpleJdbcTemplate with mocking in Unit test    forum.springsource.org

Hi all, I tried to mock up simplejdbctemplate in unit test but not successful. any one please let mw know how to mock up simplejdbctemplate... Thanks in advance Mubarak

50. setting fetchsize in SimpleJdbcTemplate    forum.springsource.org

@Test public void accessJdbcOperations() throws Exception { SimpleJdbcTemplate simpleJdbc = new SimpleJdbcTemplate(this.dataSource); assertTrue(simpleJdbc.getJdbcOperations() instanceof JdbcTemplate); ((JdbcTemplate)simpleJdbc.getJdbcOperations()).setFetchSize(100); }

51. SimpleJdbcTemplate to check the parameter values correctly mapping in SQL query    forum.springsource.org

SimpleJdbcTemplate to check the parameter values correctly mapping in SQL query I am using simpleJdbctemplate , query(sql,rowmapper,map) Method and log4j Ex: Code: List ResultList = getSimpleJdbcTemplate().query(sql,this.RowMapper, requestParamMap); When i execute the ...

52. Passing an object as a parameter - SimpleJdbcTemplate    forum.springsource.org

Passing an object as a parameter - SimpleJdbcTemplate Hi, I get a "java.sql.SQLException: Invalid argument value: java.lang.ArrayIndexOutOfBoundsException - SQL state [S1009]; error code [0];" when i tried to pass a hashmap ...

53. Difference between Spring 3's JdbcTemplate and SimpleJdbcTemplate?    forum.springsource.org

In Spring 3, the codebase was Java-5 enabled wherever appropriate. So I noticed that ParameterizedRowMapper has now been deprecated in favor of RowMapper, since the original RowMapper has generics. I noticed ...

54. simplejdbctemplate question    forum.springsource.org

Hello, If I set up a simple "save" method in my DAO (simplejdbctemplate), do I need to define transactional boundaries explicitly or will spring commit by default (without the need to ...

55. Mocking SimpleJdbcTemplate    forum.springsource.org

Mocking SimpleJdbcTemplate Hi, I was hoping someone could help me with mocking SimpleJdbcTemplate. In my DAO code, I call the SimpleJdbcTemplate.batchUpdate( String sql, List params ) method. In my test case, ...

56. How check row existence using SimpleJdbcTemplate?    forum.springsource.org

I am using SimpleJdbTemplate (2.5.6). In a test, I need to check if a value is in a (legacy) table (e.g. "select id from mytable where unique_id = 7"), it may ...

57. insert/delete using SimpleJdbcTemplate    forum.springsource.org

insert/delete using SimpleJdbcTemplate I have setup a DAO using SimpleJdbcTemplate. I am able to select but my inserts/deletes fail. I have listed the source code below. private final SimpleJdbcTemplate template; public ...

58. simpleJdbcTemplate batchUpdate issue    forum.springsource.org

simpleJdbcTemplate batchUpdate issue Hi, I am trying to use the "Insert where not exists" form of SQL insert in a batch. The idea is to query the database first for a ...

59. SimpleJdbcTemplate with Java 6    forum.springsource.org

SimpleJdbcTemplate with Java 6 Hi, I am trying to use the SimpleJdbcTemplate of Spring JNDI to establish the database connections. THe Spring configuration files are as follows ...

60. Pagination using SimpleJdbcTemplate for MySQL    forum.springsource.org

Hi I have search results page, the displays 100s records. Each page can show only 50 results. I am using SimpleJdbcTemplate and MySQL. What is the best way to implement pagination? ...

61. spring simplejdbctemplate batch update - array of strings    forum.springsource.org

could please anybody help me out with an example of batch update of an array of strings into one column ? ANSWERED: My apologies, I found out that there's no way ...

62. SimpleJdbcTemplate & Junit    forum.springsource.org

Dec 14th, 2010, 03:36 PM #1 publicstaticvoidmain View Profile View Forum Posts Private Message Junior Member Join Date Dec 2010 Posts 19 SimpleJdbcTemplate & Junit Hi all, Im new to Spring ...